diff options
| author | Mattias Andrée <maandree@kth.se> | 2016-04-24 00:41:07 +0200 |
|---|---|---|
| committer | Mattias Andrée <maandree@kth.se> | 2016-04-24 00:41:07 +0200 |
| commit | d0788650ecb3f38f4e20f9a71f449980258d3112 (patch) | |
| tree | 65404fd1b04676450a0634460d0f48d71f5b3a76 /bench/plot.py | |
| parent | Add support for benchmark against hebimath (diff) | |
| download | libzahl-d0788650ecb3f38f4e20f9a71f449980258d3112.tar.gz libzahl-d0788650ecb3f38f4e20f9a71f449980258d3112.tar.bz2 libzahl-d0788650ecb3f38f4e20f9a71f449980258d3112.tar.xz | |
bench/benchmark-func.c
Signed-off-by: Mattias Andrée <maandree@kth.se>
Diffstat (limited to 'bench/plot.py')
| -rwxr-xr-x | bench/plot.py | 51 |
1 files changed, 51 insertions, 0 deletions
diff --git a/bench/plot.py b/bench/plot.py new file mode 100755 index 0000000..3a59490 --- /dev/null +++ b/bench/plot.py @@ -0,0 +1,51 @@ +#!/usr/bin/env python3 + +import sys, os +import matplotlib.pyplot as plot + +xkcdstyle = 'XKCD_STYLE' in os.environ +if xkcdstyle: + plot.xkcd() +plot.figure() + +multiple = 1 +smultiple = '' + +for path in sys.argv[1:]: + if path.startswith('*'): + multiple = float(path[1:]) + smultiple = ' * ' + path[1:] + continue + with open(path, 'rb') as file: + lines = file.read() + lines = lines.decode('utf-8', 'strict').split('\n') + label, dim, xpoints, values = lines[0], int(lines[1]), lines[2], lines[3:] + label += smultiple + xpoints = [int(x) for x in xpoints.split(' ')] + xpoints[1] += 1 + xpoints = list(range(*xpoints)) + if dim == 3: + ypoints, values = values[0], values[1:] + ypoints = [int(x) for x in ypoints.split(' ')] + ypoints[1] += 1 + ypoints = list(range(*ypoints)) + values = [float(v) * multiple for v in values if v != ''] + if dim == 2: + if 'PER_BIT' in os.environ: + values = [y / x for y, x in zip(values, xpoints)] + plot.plot(xpoints, values, label = label) + elif dim == 3: + pass + multiple = 1 + smultiple = '' + +if dim == 2: + plot.legend(loc = 'best') + plot.xlabel('bits') + plot.ylabel('time') +elif dim == 3: + pass + +if not xkcdstyle: + plot.grid(True) +plot.show() |
