aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xbench.py32
-rw-r--r--src/dj_trace.py12
-rw-r--r--src/falsesharing.py6
-rw-r--r--src/larson.py11
-rw-r--r--src/loop.py15
-rw-r--r--src/mysql.py12
6 files changed, 46 insertions, 42 deletions
diff --git a/bench.py b/bench.py
index 7927578..7a3b0f9 100755
--- a/bench.py
+++ b/bench.py
@@ -1,9 +1,12 @@
#!/usr/bin/env python3
import argparse
+import datetime
import importlib
import os
+import src.facter
+
benchmarks = ["loop", "mysql", "falsesharing", "dj_trace", "larson"]
parser = argparse.ArgumentParser(description="benchmark memory allocators")
@@ -13,7 +16,7 @@ parser.add_argument("-r", "--runs", help="how often the benchmarks run", default
parser.add_argument("-v", "--verbose", help="more output", action='store_true')
parser.add_argument("-b", "--benchmarks", help="benchmarks to run", nargs='+')
parser.add_argument("-ns", "--nosum", help="don't produce plots", action='store_true')
-parser.add_argument("-sd", "--summarydir", help="directory where all plots and the summary go", type=str)
+parser.add_argument("-sd", "--resultdir", help="directory where all results go", type=str)
parser.add_argument("-a", "--analyse", help="collect allocation sizes", action='store_true')
parser.add_argument("--nolibmemusage", help="don't use libmemusage to analyse", action='store_true')
parser.add_argument("--license", help="print license info and exit", action='store_true')
@@ -27,8 +30,13 @@ def main():
if args.verbose:
print(args)
- if args.summarydir and not os.path.isdir(args.summarydir):
- os.makedirs(args.summarydir)
+ if args.save or not args.nosum and not (args.runs < 1 and not args.load):
+ if args.resultdir:
+ resdir = os.path.join(args.resultdir)
+ else:
+ resdir = os.path.join("results", src.facter.get_hostname(),
+ datetime.datetime.now().strftime("%Y-%m-%dT%H:%M"))
+ os.makedirs(resdir)
for bench in benchmarks:
bench = eval("importlib.import_module('src.{0}').{0}".format(bench))
@@ -51,12 +59,20 @@ def main():
if not bench.run(runs=args.runs, verbose=args.verbose):
continue
- if args.save:
- bench.save()
+ if args.save or not args.nosum and not (args.runs < 1 and not args.load):
+ old_cwd = os.getcwd()
+ os.chdir(resdir)
+
+ if args.save:
+ bench.save()
+
+ if not args.nosum and not (args.runs < 1 and not args.load):
+ os.mkdir(bench.name)
+ os.chdir(bench.name)
+ print("Summarizing", bench.name, "...")
+ bench.summary()
- if not args.nosum and not (args.runs < 1 and not args.load):
- print("Summarizing", bench.name, "...")
- bench.summary(args.summarydir or "")
+ os.chdir(old_cwd)
if (args.runs > 0 or args.analyse) and hasattr(bench, "cleanup"):
print("Cleaning up", bench.name, "...")
diff --git a/src/dj_trace.py b/src/dj_trace.py
index 18509b3..21b9ddd 100644
--- a/src/dj_trace.py
+++ b/src/dj_trace.py
@@ -127,12 +127,10 @@ class Benchmark_DJ_Trace( Benchmark ):
fname = functions[i]
result["avg_" + fname] = to_int(res.group("time"))
- def summary(self, sd=None):
+ def summary(self):
args = self.results["args"]
targets = self.results["targets"]
- sd = sd or ""
-
# Total times
for perm in self.iterate_args(args=args):
for i, target in enumerate(targets):
@@ -146,7 +144,7 @@ class Benchmark_DJ_Trace( Benchmark ):
plt.legend(loc="best")
plt.ylabel("Zeit in ms")
plt.title("Gesamte Laufzeit")
- plt.savefig(os.path.join(sd, ".".join([self.name, perm.workload, "runtime", "png"])))
+ plt.savefig(".".join([self.name, perm.workload, "runtime", "png"]))
plt.clf()
# Function Times
@@ -169,7 +167,7 @@ class Benchmark_DJ_Trace( Benchmark ):
"free\n" + str(self.results[perm.workload]["free"]) + "\ncalls"])
plt.ylabel("Durchschnittliche Zeit in cycles")
plt.title("Durchscnittliche Laufzeiten der API Funktionen")
- plt.savefig(os.path.join(sd, ".".join([self.name, perm.workload, "apitimes", "png"])))
+ plt.savefig(".".join([self.name, perm.workload, "apitimes", "png"]))
plt.clf()
# Memusage
@@ -189,7 +187,7 @@ class Benchmark_DJ_Trace( Benchmark ):
plt.legend(loc="best")
plt.ylabel("Max RSS in MB")
plt.title("Maximal benötigter Speicher (VmHWM)")
- plt.savefig(os.path.join(sd, ".".join([self.name, perm.workload, "rss", "png"])))
+ plt.savefig(".".join([self.name, perm.workload, "rss", "png"]))
plt.clf()
# Tables
@@ -208,7 +206,7 @@ class Benchmark_DJ_Trace( Benchmark ):
rssmin = min(rss)
rssmax = max(rss)
- fname = os.path.join(sd, ".".join([self.name, perm.workload, "table.tex"]))
+ fname = ".".join([self.name, perm.workload, "table.tex"])
with open(fname, "w") as f:
print("\\begin{tabular}{| l | l | l |}" , file=f)
print("& Zeit (ms) / $\\sigma$ (\\%) & VmHWM (KB) / $\\sigma$ (\\%) \\\\", file=f)
diff --git a/src/falsesharing.py b/src/falsesharing.py
index 1e0ef18..57acf06 100644
--- a/src/falsesharing.py
+++ b/src/falsesharing.py
@@ -29,7 +29,7 @@ class Benchmark_Falsesharing( Benchmark ):
def process_output(self, result, stdout, stderr, target, perm, verbose):
result["time"] = time_re.match(stdout).group("time")
- def summary(self, sumdir=None):
+ def summary(self):
# Speedup thrash
args = self.results["args"]
nthreads = args["threads"]
@@ -56,21 +56,19 @@ class Benchmark_Falsesharing( Benchmark ):
plt.xlabel("threads")
plt.ylabel("speedup")
plt.title(bench + " speedup" )
- plt.savefig(os.path.join(sumdir, self.name + "." + bench + ".png"))
+ plt.savefig(self.name + "." + bench + ".png")
plt.clf()
self.plot_fixed_arg("({L1-dcache-load-misses}/{L1-dcache-loads})*100",
ylabel="'l1 cache misses in %'",
title = "'cache misses: ' + arg + ' ' + str(arg_value)",
filepostfix = "l1-misses",
- sumdir=sumdir,
fixed=["bench"])
self.plot_fixed_arg("({LLC-load-misses}/{LLC-loads})*100",
ylabel="'l1 cache misses in %'",
title = "'LLC misses: ' + arg + ' ' + str(arg_value)",
filepostfix = "llc-misses",
- sumdir=sumdir,
fixed=["bench"])
falsesharing = Benchmark_Falsesharing()
diff --git a/src/larson.py b/src/larson.py
index 713818b..0a4a237 100644
--- a/src/larson.py
+++ b/src/larson.py
@@ -30,25 +30,22 @@ class Benchmark_Larson( Benchmark ):
result["throughput"] = int(res.group("throughput"))
return
- def summary(self, sumdir):
+ def summary(self):
# Plot threads->throughput and maxsize->throughput
self.plot_fixed_arg("{throughput}/1000000",
ylabel="'MOPS/s'",
title = "'Larson: ' + arg + ' ' + str(arg_value)",
- filepostfix = "throughput",
- sumdir=sumdir)
+ filepostfix = "throughput")
self.plot_fixed_arg("({L1-dcache-load-misses}/{L1-dcache-loads})*100",
ylabel="'l1 cache misses in %'",
title = "'Larson cache misses: ' + arg + ' ' + str(arg_value)",
- filepostfix = "cachemisses",
- sumdir=sumdir)
+ filepostfix = "cachemisses")
# Memusage
self.plot_fixed_arg("int({VmHWM})",
ylabel='"VmHWM in kB"',
title= '"Loop Memusage: " + arg + " " + str(arg_value)',
- filepostfix="memusage",
- sumdir=sumdir)
+ filepostfix="memusage")
larson = Benchmark_Larson()
diff --git a/src/loop.py b/src/loop.py
index 9590710..d58b4e2 100644
--- a/src/loop.py
+++ b/src/loop.py
@@ -19,30 +19,27 @@ class Benchmark_Loop( Benchmark ):
self.requirements = ["build/bench_loop"]
super().__init__()
- def summary(self, sumdir):
+ def summary(self):
# Speed
self.plot_fixed_arg("perm.nthreads / (float({task-clock})/1000)",
ylabel = '"MOPS/cpu-second"',
title = '"Loop: " + arg + " " + str(arg_value)',
- filepostfix="time",
- sumdir=sumdir)
+ filepostfix="time")
# Memusage
self.plot_fixed_arg("int({VmHWM})",
ylabel='"VmHWM in kB"',
title= '"Loop Memusage: " + arg + " " + str(arg_value)',
- filepostfix="memusage",
- sumdir=sumdir)
+ filepostfix="memusage")
+ # L1 cache misses
self.plot_fixed_arg("({L1-dcache-load-misses}/{L1-dcache-loads})*100",
ylabel='"L1 misses in %"',
title= '"Loop l1 cache misses: " + arg + " " + str(arg_value)',
- filepostfix="l1misses",
- sumdir=sumdir)
+ filepostfix="l1misses")
# Speed Matrix
self.write_best_doublearg_tex_table("perm.nthreads / (float({task-clock})/1000)",
- filepostfix="memusage.matrix",
- sumdir=sumdir)
+ filepostfix="memusage.matrix")
loop = Benchmark_Loop()
diff --git a/src/mysql.py b/src/mysql.py
index ac97998..6d19a97 100644
--- a/src/mysql.py
+++ b/src/mysql.py
@@ -186,7 +186,7 @@ class Benchmark_MYSQL( Benchmark ):
return False
print()
- def summary(self, sd):
+ def summary(self):
targets = self.results["targets"]
args = self.results["args"]
nthreads = list(args["nthreads"])
@@ -196,8 +196,7 @@ class Benchmark_MYSQL( Benchmark ):
xlabel = '"threads"',
ylabel = '"transactions"',
title = '"sysbench oltp read only"',
- filepostfix = "l.ro",
- sumdir = sd)
+ filepostfix = "l.ro")
# bar plot
for i, target in enumerate(targets):
@@ -214,7 +213,7 @@ class Benchmark_MYSQL( Benchmark ):
plt.xticks(range(1, len(y_vals) + 1), self.results["args"]["nthreads"])
plt.ylabel("transactions")
plt.title("sysbench oltp read only")
- plt.savefig(os.path.join(sd, self.name + ".b.ro.png"))
+ plt.savefig(self.name + ".b.ro.png")
plt.clf()
# Memusage
@@ -222,8 +221,7 @@ class Benchmark_MYSQL( Benchmark ):
xlabel = '"threads"',
ylabel = '"VmHWM in kB"',
title = '"Memusage sysbench oltp read only"',
- filepostfix = "ro.mem",
- sumdir = sd)
+ filepostfix = "ro.mem")
# Colored latex table showing transactions count
d = {target: {} for target in targets}
@@ -248,7 +246,7 @@ class Benchmark_MYSQL( Benchmark ):
maxs[perm] = cmax
mins[perm] = cmin
- fname = os.path.join(sd, ".".join([self.name, "transactions.tex"]))
+ fname = ".".join([self.name, "transactions.tex"])
headers = [perm.nthreads for perm in self.iterate_args(args=args)]
with open(fname, "w") as f:
print("\\begin{tabular}{| l" + " l"*len(headers) + " |}" , file=f)