diff options
author | Michael Hope <michael.hope@linaro.org> | 2011-08-31 16:29:00 +1200 |
---|---|---|
committer | Michael Hope <michael.hope@linaro.org> | 2011-08-31 16:29:00 +1200 |
commit | f7afc0219e7da84daa71d89b7a3db7960974df32 (patch) | |
tree | b46aec92f1d8b70cee1e9ef20713358e496c52c1 /scripts | |
parent | ff5cd9ca4f7233af9f8ce51dc2777b43c65b1b9c (diff) |
Added more ranges. changed everything to MB/s. Account for the loop overhead.
Diffstat (limited to 'scripts')
-rw-r--r-- | scripts/bench.py | 23 | ||||
-rw-r--r-- | scripts/libplot.py | 34 | ||||
-rw-r--r-- | scripts/plot-sizes.py | 4 | ||||
-rw-r--r-- | scripts/plot-top.py | 18 |
4 files changed, 63 insertions, 16 deletions
diff --git a/scripts/bench.py b/scripts/bench.py index aa0e6fc..e99ab4a 100644 --- a/scripts/bench.py +++ b/scripts/bench.py @@ -16,15 +16,19 @@ def run(cache, variant, function, bytes, loops): xbuild = build cmd = '%(xbuild)s%(variant)s -t %(function)s -c %(bytes)s -l %(loops)s' % locals() - got = subprocess.check_output(cmd.split()).strip() - cache[key] = got - print got + try: + got = subprocess.check_output(cmd.split()).strip() + cache[key] = got + print got + except OSError, ex: + assert False, 'Error %s while running %s' % (ex, cmd) sys.stdout.flush() def run_bytes(cache, variant, function, bytes): for b in bytes: + # Figure out the number of loops to give a roughly consistent run loops = int(500000000/5 / math.sqrt(b)) run(cache, variant, function, b, loops) @@ -35,8 +39,8 @@ def run_functions(cache, variant, functions, bytes): HAS = { - 'this': 'strcmp strcpy memchr strchr strlen memcpy memset', - 'bionc': 'strlen memset memcpy', + 'this': 'bounce strcmp strcpy memchr strchr strlen memcpy memset', + 'bionic': 'strlen memset memcpy', 'glibc': 'memset strlen memcpy strcmp strcpy memchr strchr', 'newlib': 'strcmp strlen strcpy', 'plain': 'memset memcpy strcmp strcpy', @@ -56,7 +60,11 @@ def run_variants(cache, variants, bytes): def run_top(cache): variants = HAS.keys() - bytes = [2**x for x in range(1, 12)] + power2 = [2**x for x in range(1, 12)] + minus1 = [x-1 for x in power2] + various = [int(1.7*x) for x in range(1, 12)] + + bytes = sorted(set(power2 + minus1 + various)) run_variants(cache, variants, bytes) @@ -81,4 +89,5 @@ def main(): for line in cache.values(): print >> f, line -main() +if __name__ == '__main__': + main() diff --git a/scripts/libplot.py b/scripts/libplot.py index f83d142..129d79f 100644 --- a/scripts/libplot.py +++ b/scripts/libplot.py @@ -1,3 +1,5 @@ +"""Shared routines for the plotters.""" + import fileinput import collections @@ -5,6 +7,7 @@ Record = collections.namedtuple('Record', 'variant function bytes loops elapsed def parse_value(v): + """Turn text into a primitive""" try: return float(v) except ValueError: @@ -12,9 +15,38 @@ def parse_value(v): def unique(records, name): + """Return the unique values of a column in the records""" values = set(getattr(x, name) for x in records) return sorted(values) def parse(): - return [Record(*[parse_value(y) for y in x.split(':')]) for x in fileinput.input()] + """Parse a record file into named tuples, correcting for loop + overhead along the way. + """ + records = [Record(*[parse_value(y) for y in x.split(':')]) for x in fileinput.input()] + + # Pull out any bounce values + costs = {} + + for record in [x for x in records if x.function=='bounce']: + costs[(record.bytes, record.loops)] = record.elapsed + + # Fix up all of the records for cost + out = [] + + for record in records: + if record.function == 'bounce': + continue + + cost = costs.get((record.bytes, record.loops), None) + + if not cost: + out.append(record) + else: + # Unfortunately you can't update a namedtuple... + values = list(record) + values[-2] -= cost + out.append(Record(*values)) + + return out diff --git a/scripts/plot-sizes.py b/scripts/plot-sizes.py index d1fbdf9..0e05f4e 100644 --- a/scripts/plot-sizes.py +++ b/scripts/plot-sizes.py @@ -16,6 +16,7 @@ def plot(records, function): bytes = libplot.unique(records, 'bytes') colours = iter('bgrcmyk') + all_x = [] pylab.clf() @@ -26,6 +27,7 @@ def plot(records, function): X = [x.bytes for x in matches] Y = [x.bytes*x.loops/x.elapsed/(1024*1024) for x in matches] + all_x.extend(X) colour = colours.next() if X: @@ -38,7 +40,7 @@ def plot(records, function): pylab.xlabel('Size (B)') pylab.ylabel('Rate (MB/s)') pylab.semilogx() - pylab.xlim(0, max(X)) + pylab.xlim(0, max(all_x)) pylab.ylim(0, pylab.ylim()[1]) def main(): diff --git a/scripts/plot-top.py b/scripts/plot-top.py index 02dc571..4cf1965 100644 --- a/scripts/plot-top.py +++ b/scripts/plot-top.py @@ -1,7 +1,7 @@ #!/usr/bin/env python -"""Plot the results of benchmarking different variants of the string -routines for one size. +"""Plot the performance of different variants of the string routines +for one size. """ import libplot @@ -9,10 +9,7 @@ import libplot import pylab -def main(): - bytes = 64 - - records = libplot.parse() +def plot(records, bytes): records = [x for x in records if x.bytes==bytes] variants = libplot.unique(records, 'variant') @@ -31,7 +28,7 @@ def main(): if matches: match = matches[0] - heights.append(match.bytes*match.loops/match.elapsed) + heights.append(match.bytes*match.loops/match.elapsed/(1024*1024)) else: heights.append(0) @@ -41,8 +38,15 @@ def main(): axes.set_xticklabels(functions) axes.set_xticks(X + 0.5) + pylab.title('Performance of different variants for %d byte blocks' % bytes) + pylab.ylabel('Rate (MB/s)') pylab.legend() pylab.grid() + pylab.savefig('top-%d.png' % bytes) + +def main(): + records = libplot.parse() + plot(records, 64) pylab.show() if __name__ == '__main__': |