diff options
| author | Mattias Andrée <maandree@kth.se> | 2016-05-01 23:21:27 +0200 |
|---|---|---|
| committer | Mattias Andrée <maandree@kth.se> | 2016-05-01 23:21:27 +0200 |
| commit | 068fc72f804ef972a35f06b06b049a84db1ce6a7 (patch) | |
| tree | f789abbb720db0e4b45e2547bae2b7a568efd818 /bench/plot.py | |
| parent | Comments from 1-bit 4097-bit benchmarks (diff) | |
| download | libzahl-068fc72f804ef972a35f06b06b049a84db1ce6a7.tar.gz libzahl-068fc72f804ef972a35f06b06b049a84db1ce6a7.tar.bz2 libzahl-068fc72f804ef972a35f06b06b049a84db1ce6a7.tar.xz | |
Benchmarking stuff
Signed-off-by: Mattias Andrée <maandree@kth.se>
Diffstat (limited to 'bench/plot.py')
| -rwxr-xr-x | bench/plot.py | 74 |
1 files changed, 64 insertions, 10 deletions
diff --git a/bench/plot.py b/bench/plot.py index 3a59490..4e68977 100755 --- a/bench/plot.py +++ b/bench/plot.py @@ -1,4 +1,21 @@ #!/usr/bin/env python3 +# See LICENSE file for copyright and license details. + + +# Invoke using `env XKCD_STYLE=` to for more a comical plot style. + +# Invoke using `env PER_BIT=` to divide all time values by the number +# of bits that where processed. This applies to 2-dimensional data only. + +# Invoke using `env VIOLIN_STYLE=` to draw violin plots rather than +# box plots. This applies to multisample 1-dimensional data only. +# If used, used `env SHOW_MEAN=` will show that mean value in place +# of the median value. + +# For multisample 1-dimensional, if `env VIOLIN_STYLE=` is not used +# `env NOTCH_STYLE=`, `env PATCH_ARTIST`, and `env SHOW_MEAN` may be +# applied. + import sys, os import matplotlib.pyplot as plot @@ -6,11 +23,16 @@ import matplotlib.pyplot as plot xkcdstyle = 'XKCD_STYLE' in os.environ if xkcdstyle: plot.xkcd() -plot.figure() +fig = plot.figure() multiple = 1 smultiple = '' +labels_1d = [] +values_1d = [] + +xint = lambda x : (float(x) if '.' in x else int(x)) + for path in sys.argv[1:]: if path.startswith('*'): multiple = float(path[1:]) @@ -19,18 +41,22 @@ for path in sys.argv[1:]: 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: + label, dim, values = lines[0] + smultiple, int(lines[1]), lines[2:] + if dim > 1: + xpoints, values = values[0], values[1:] + xpoints = [int(x) for x in xpoints.split(' ')] + xpoints[1] += 1 + xpoints = list(range(*xpoints)) + if dim > 2: 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: + values = [xint(v) * multiple for v in values if v != ''] + if dim == 1: + labels_1d.append(label) + values_1d.append(values) + elif dim == 2: if 'PER_BIT' in os.environ: values = [y / x for y, x in zip(values, xpoints)] plot.plot(xpoints, values, label = label) @@ -39,7 +65,35 @@ for path in sys.argv[1:]: multiple = 1 smultiple = '' -if dim == 2: +if dim == 1: + plot.ylabel('time') + if len(values_1d[0]) == 1: + plot.bar(range(len(values_1d)), + [vs[0] for vs in values_1d], + align = 'center', + orientation = 'vertical', + tick_label = labels_1d) + labels_1d = None + elif 'VIOLIN_STYLE' in os.environ: + plot.violinplot(values_1d, + vert = True, + showmeans = 'SHOW_MEAN' in os.environ, + showmedians = 'SHOW_MEAN' not in os.environ, + showextrema = True) + else: + plot.boxplot(values_1d, + vert = True, + notch = 'NOTCH_STYLE' in os.environ, + patch_artist = 'PATCH_ARTIST' in os.environ) + if 'SHOW_MEAN' in os.environ: + for i in range(len(values_1d)): + mean = sum(values_1d[i]) / len(values_1d[i]) + plot.plot([i + 0.75, i + 1.25], [mean, mean]); + if labels_1d is not None: + plot.setp(fig.axes, + xticks = [x + 1 for x in range(len(values_1d))], + xticklabels = labels_1d) +elif dim == 2: plot.legend(loc = 'best') plot.xlabel('bits') plot.ylabel('time') |
