aboutsummaryrefslogtreecommitdiff
path: root/bench_conprod.py
diff options
context:
space:
mode:
authorFlorian Fischer <florian.fl.fischer@fau.de>2018-07-20 14:17:04 +0200
committerFlorian Fischer <florian.fl.fischer@fau.de>2018-07-20 14:17:04 +0200
commit78098dbe189ae84b38cf6c94cbe06dafd07cb10c (patch)
treea637cc1cc44dd3f0ddce3a47e9887bb546774adb /bench_conprod.py
parent08cdc1d18cd8371b38ef1a6bf663ca32bb951c9e (diff)
downloadallocbench-78098dbe189ae84b38cf6c94cbe06dafd07cb10c.tar.gz
allocbench-78098dbe189ae84b38cf6c94cbe06dafd07cb10c.zip
make results independant and add cmdline options
Diffstat (limited to 'bench_conprod.py')
-rw-r--r--bench_conprod.py46
1 files changed, 25 insertions, 21 deletions
diff --git a/bench_conprod.py b/bench_conprod.py
index 21e4b13..60a9889 100644
--- a/bench_conprod.py
+++ b/bench_conprod.py
@@ -6,14 +6,16 @@ import numpy as np
import os
import subprocess
+from benchmark import Benchmark
from common_targets import common_targets
cmd = ("perf stat -x\; -e cpu-clock:k,cache-references,cache-misses,cycles,"
"instructions,branches,faults,migrations "
"build/bench_conprod{0} {1} {1} {1} 1000000 {2}")
-class Benchmark_ConProd():
+class Benchmark_ConProd( Benchmark ):
def __init__(self):
+ self.file_name = "bench_conprod"
self.name = "Consumer Producer Stress Benchmark"
self.descrition = """This benchmark makes 1000000 allocations in each of
n producer threads. The allocations are shared through n
@@ -22,8 +24,9 @@ class Benchmark_ConProd():
self.maxsize = [2 ** x for x in range(6, 16)]
self.nthreads = range(1, multiprocessing.cpu_count() + 1)
- self.results = {}
-
+ self.results = {"args" : {"nthreads" : self.nthreads, "maxsize" : self.maxsize},
+ "targets" : self.targets}
+
def prepare(self, verbose=False):
req = ["build/bench_conprod"]
for r in req:
@@ -36,9 +39,8 @@ class Benchmark_ConProd():
if verbose:
print(r, "found and executable.")
return True
-
- def run(self, verbose=False, save=False, runs=3):
+ def run(self, verbose=False, runs=3):
args_permutations = [(x,y) for x in self.nthreads for y in self.maxsize]
n = len(args_permutations)
for run in range(1, runs + 1):
@@ -95,38 +97,40 @@ class Benchmark_ConProd():
self.results[key].append(result)
print()
- if save:
- with open(self.name + ".save", "wb") as f:
- pickle.dump(self.results, f)
return True
def summary(self):
# MAXSIZE fixed
- for size in self.maxsize:
- for target in self.targets:
- y_vals = [0] * len(self.nthreads)
+ nthreads = self.results["args"]["nthreads"]
+ maxsize = self.results["args"]["maxsize"]
+ targets = self.results["targets"]
+
+ y_mapping = {v : i for i, v in enumerate(nthreads)}
+ for size in maxsize:
+ for target in targets:
+ y_vals = [0] * len(nthreads)
for mid, measures in self.results.items():
if mid[0] == target and mid[2] == size:
d = []
for m in measures:
# nthreads/time = MOPS/S
d.append(mid[1]/float(m["cpu-clock:ku"]))
- y_vals[mid[1]-1] = np.mean(d)
- plt.plot(self.nthreads, y_vals, label=target, linestyle='-', marker='.')
+ y_vals[y_mapping[mid[1]]] = np.mean(d)
+ plt.plot(nthreads, y_vals, label=target, linestyle='-', marker='.')
plt.legend()
plt.xlabel("consumers/producers")
plt.ylabel("MOPS/s")
plt.title("Consumer Producer: " + str(size) + "B")
- plt.savefig("Conprod." + str(size) + "B.png")
+ plt.savefig(self.file_name + "." + str(size) + "B.png")
plt.clf()
# NTHREADS fixed
- y_mapping = {v : i for i, v in enumerate(self.maxsize)}
- x_vals = [i + 1 for i in range(0, len(self.maxsize))]
- for n in self.nthreads:
- for target in self.targets:
- y_vals = [0] * len(self.maxsize)
+ y_mapping = {v : i for i, v in enumerate(maxsize)}
+ x_vals = [i + 1 for i in range(0, len(maxsize))]
+ for n in nthreads:
+ for target in targets:
+ y_vals = [0] * len(maxsize)
for mid, measures in self.results.items():
if mid[0] == target and mid[1] == n:
d = []
@@ -137,11 +141,11 @@ class Benchmark_ConProd():
plt.plot(x_vals, y_vals, label=target, linestyle='-', marker='.')
plt.legend()
- plt.xticks(x_vals, self.maxsize)
+ plt.xticks(x_vals, maxsize)
plt.xlabel("size in B")
plt.ylabel("MOPS/s")
plt.title("Consumer Producer: " + str(n) + "thread(s)")
- plt.savefig("Conprod." + str(n) + "thread.png")
+ plt.savefig(self.file_name + "." + str(n) + "thread.png")
plt.clf()
conprod = Benchmark_ConProd()