summaryrefslogtreecommitdiff
path: root/benchmark
diff options
context:
space:
mode:
authorJosh Blum2013-01-13 20:36:12 -0800
committerJosh Blum2013-01-13 20:36:12 -0800
commit4bdd10a2ab4d71bfc9dcee561a7ebb64c43df43f (patch)
treea9d57d74c6098fc4eea163036cde62724192f4e5 /benchmark
parentc736d8751fbe825bc4307e666d6dfd95fce349f4 (diff)
downloadsandhi-4bdd10a2ab4d71bfc9dcee561a7ebb64c43df43f.tar.gz
sandhi-4bdd10a2ab4d71bfc9dcee561a7ebb64c43df43f.tar.bz2
sandhi-4bdd10a2ab4d71bfc9dcee561a7ebb64c43df43f.zip
benchmark: script now produces barplots in pdf format
Diffstat (limited to 'benchmark')
-rw-r--r--benchmark/benchmark.py56
1 files changed, 52 insertions, 4 deletions
diff --git a/benchmark/benchmark.py b/benchmark/benchmark.py
index c2d0aa8..b8e7e9a 100644
--- a/benchmark/benchmark.py
+++ b/benchmark/benchmark.py
@@ -2,8 +2,13 @@ import sys
import os
import time
import subprocess
-import pylab as p
import copy
+import numpy
+
+from matplotlib.backends.backend_pdf import PdfPages
+from matplotlib.backends.backend_agg import FigureCanvasAgg as FigureCanvas
+from matplotlib.figure import Figure
+from matplotlib.font_manager import FontProperties
__path__ = os.path.dirname(__file__)
@@ -44,13 +49,18 @@ BENCHMARK_MANY_11_BLOCKS = tokwargs(
wat='Benchmark the schedulers with many 1:1 blocks',
moar='''TODO''',
tests = [
- tokwargs(wat='Many 1:1 GRAS - Default', args=['tb_many_1_to_1_blocks.py', '1e8'], env=GRAS_ENV),
+ tokwargs(wat='Many 1:1 GRAS', args=['tb_many_1_to_1_blocks.py', '1e8'], env=GRAS_ENV),
#tokwargs(wat='Many 1:1 GRAS - TPP', args=['tb_many_1_to_1_blocks.py', '1e8'], env=GRAS_ENV, envextra=tokwargs(GRAS_TPP='1')),
tokwargs(wat='Many 1:1 GR', args=['tb_many_1_to_1_blocks.py', '1e8'], env=GR_ENV),
],
to_result = lambda t: 1e8/t
)
+BENCHMARKS = (
+ BENCHMARK_MATH_OPS,
+ BENCHMARK_MANY_11_BLOCKS,
+)
+
def time_a_single_one(args, env):
print env
t0 = time.time()
@@ -61,7 +71,9 @@ def time_a_single_one(args, env):
def do_a_benchmark(bm):
results = list()
+ test_names = list()
for run in bm['tests']:
+ test_names.append(run['wat'])
args = run['args']
args[0] = os.path.join(__path__, args[0])
args = [sys.executable] + args
@@ -73,6 +85,42 @@ def do_a_benchmark(bm):
results.append(bm['to_result'](r))
print results
+ bogomips = numpy.array(results)/1e6
+ ind = numpy.arange(len(test_names))
+ width = 0.35
+ fig = Figure()
+ fig.set_size_inches((11,8.5))
+ FigureCanvas(fig)
+ ax = fig.add_subplot(1, 1, 1,
+ ylabel='Performance (BogoMips)', title=bm['wat'],
+ xlabel='', xticks=ind+width/2., xticklabels=test_names
+ )
+ rects = ax.bar(ind, bogomips, width, color='blue')
+ ax.set_xlim(-width, max(len(ind), 4))
+ ax.set_ylim(0, max(*bogomips) + numpy.std(bogomips))
+ for rect in rects:
+ height = rect.get_height()
+ ax.text(rect.get_x()+rect.get_width()/2.0, 1.03*height, '%.3f'%height, horizontalalignment='center')
+ ax.grid(True)
+ return fig
+
+
if __name__ == '__main__':
- #do_a_benchmark(BENCHMARK_MATH_OPS)
- do_a_benchmark(BENCHMARK_MANY_11_BLOCKS)
+ ####################################################################
+ ## create pdf generator
+ ####################################################################
+ pdf_pages = PdfPages('gras_benchmark.pdf')
+
+ ####################################################################
+ ## loop through tests
+ ####################################################################
+ for bm in BENCHMARKS:
+ fig = do_a_benchmark(bm)
+ pdf_pages.savefig(fig)
+
+ ####################################################################
+ ## done
+ ####################################################################
+ print 'make pdf...'
+ pdf_pages.close()
+ print 'done!'