aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFlorian Fischer <florian.fl.fischer@fau.de>2019-08-29 12:14:32 +0200
committerFlorian Fischer <florian.fl.fischer@fau.de>2019-08-29 12:14:32 +0200
commit4499b5380b97ac0d64e3ba8701f1b8638609b420 (patch)
treee0e531c4b94f78ed29b1380d061a255be8f19244
parentaf68be15d93ed6ff737bbd2d503e38911f240e9a (diff)
downloadallocbench-4499b5380b97ac0d64e3ba8701f1b8638609b420.tar.gz
allocbench-4499b5380b97ac0d64e3ba8701f1b8638609b420.zip
require a name in Benchmark.__init__
-rw-r--r--doc/Benchmarks.md15
-rw-r--r--src/benchmark.py31
-rw-r--r--src/benchmarks/cfrac.py4
-rw-r--r--src/benchmarks/dj_trace.py4
-rw-r--r--src/benchmarks/espresso.py7
-rw-r--r--src/benchmarks/falsesharing.py4
-rw-r--r--src/benchmarks/httpd.py4
-rw-r--r--src/benchmarks/larson.py4
-rw-r--r--src/benchmarks/lld.py4
-rw-r--r--src/benchmarks/loop.py4
-rw-r--r--src/benchmarks/mysql.py4
-rw-r--r--src/benchmarks/realloc.py6
-rw-r--r--src/benchmarks/t_test1.py4
13 files changed, 47 insertions, 48 deletions
diff --git a/doc/Benchmarks.md b/doc/Benchmarks.md
index b173f5c..e883afb 100644
--- a/doc/Benchmarks.md
+++ b/doc/Benchmarks.md
@@ -75,12 +75,6 @@ Delorie using the tools from dj/malloc branch of the glibc.
from src.benchmark import Benchmark
-NAME = "loop"
-
-CMD = "loop{binary_suffix} {nthreads} 1000000 {maxsize}"
-
-ARGS = {"maxsize": [2 ** x for x in range(6, 16)],
- "nthreads": Benchmark.scale_threads_for_cpus(2)}
class BenchmarkLoop(Benchmark):
"""Loop micro benchmark
@@ -89,8 +83,15 @@ class BenchmarkLoop(Benchmark):
"""
def __init__(self):
+ name = "loop"
+
+ self.cmd = "loop{binary_suffix} {nthreads} 1000000 {maxsize}"
+
+ self.args = {"maxsize": [2 ** x for x in range(6, 16)],
+ "nthreads": Benchmark.scale_threads_for_cpus(2)}
+
self.requirements = ["loop"]
- super().__init__(NAME, CMD, ARGS)
+ super().__init__(name)
def summary(self):
# Speed
diff --git a/src/benchmark.py b/src/benchmark.py
index 9bf5b55..5d86918 100644
--- a/src/benchmark.py
+++ b/src/benchmark.py
@@ -20,18 +20,17 @@ from src.util import print_info0, print_info, print_debug
nan = np.NaN
-class Benchmark (object):
+class Benchmark:
"""Default implementation of most methods allocbench expects from a benchmark"""
+ # class member to remember if we are allowed to use perf
perf_allowed = None
- defaults = {
- "name": "default_benchmark",
- "measure_cmd": "perf stat -x, -d",
- "cmd": "true",
- "server_cmds": [],
- "allocators": copy.deepcopy(src.globalvars.allocators),
- }
+ defaults = {"cmd": "false",
+ "args": {},
+ "measure_cmd": "perf stat -x, -d",
+ "server_cmds": [],
+ "allocators": copy.deepcopy(src.globalvars.allocators)}
@staticmethod
def terminate_subprocess(popen, timeout=5):
@@ -76,21 +75,23 @@ class Benchmark (object):
def __str__(self):
return self.name
- def __init__(self):
+ def __init__(self, name):
+ """Initialize a benchmark with default members if they aren't set already"""
+ self.name = name
+
# Set default values
for k in Benchmark.defaults:
if not hasattr(self, k):
setattr(self, k, Benchmark.defaults[k])
+ # List of Popen server objects
+ self.servers = []
+
# Set result_dir
if not hasattr(self, "result_dir"):
self.result_dir = os.path.abspath(os.path.join(src.globalvars.resdir,
self.name))
- # non copy types
- if not hasattr(self, "args"):
- self.args = {}
-
self.Perm = namedtuple("Perm", self.args.keys())
default_results = {"args": self.args,
@@ -179,12 +180,13 @@ class Benchmark (object):
self.calc_desc_statistics()
def prepare(self):
+ """default prepare implementation raising an error if a requirement is not found"""
os.environ["PATH"] += f"{os.pathsep}{src.globalvars.builddir}/benchmarks/{self.name}"
for r in self.requirements:
exe = src.util.find_cmd(r)
if exe is not None:
- self.results["facts"]["libcs"][r] = src.facter.libc_ver(bin=exe)
+ self.results["facts"]["libcs"][r] = src.facter.libc_ver(executable=exe)
else:
raise Exception("Requirement: {} not found".format(r))
@@ -220,7 +222,6 @@ class Benchmark (object):
Servers are not allowed to deamonize because then they can't
be terminated with their Popen object."""
- self.servers = []
substitutions = {"alloc": alloc_name,
"perm": alloc_name,
diff --git a/src/benchmarks/cfrac.py b/src/benchmarks/cfrac.py
index d2b5286..cfd2fb1 100644
--- a/src/benchmarks/cfrac.py
+++ b/src/benchmarks/cfrac.py
@@ -22,14 +22,14 @@ from src.benchmark import Benchmark
class BenchmarkCfrac(Benchmark):
"""TODO"""
def __init__(self):
- self.name = "cfrac"
+ name = "cfrac"
self.cmd = "cfrac{binary_suffix} {num}"
self.args = {"num": [175451865205073170563711388363274837927895]}
self.requirements = ["cfrac"]
- super().__init__()
+ super().__init__("cfrac")
def summary(self):
# Speed
diff --git a/src/benchmarks/dj_trace.py b/src/benchmarks/dj_trace.py
index 155f3ec..ee2f161 100644
--- a/src/benchmarks/dj_trace.py
+++ b/src/benchmarks/dj_trace.py
@@ -54,7 +54,7 @@ class BenchmarkDJTrace(Benchmark):
"""
def __init__(self):
- self.name = "dj_trace"
+ name = "dj_trace"
self.cmd = "trace_run{binary_suffix} dj_workloads/{workload}.wl"
self.measure_cmd = ""
@@ -99,7 +99,7 @@ class BenchmarkDJTrace(Benchmark):
"realloc": 117, "free": 10099261, "threads": 19}}
self.requirements = ["trace_run"]
- super().__init__()
+ super().__init__(name)
def prepare(self):
super().prepare()
diff --git a/src/benchmarks/espresso.py b/src/benchmarks/espresso.py
index 2e3d47a..a565132 100644
--- a/src/benchmarks/espresso.py
+++ b/src/benchmarks/espresso.py
@@ -25,15 +25,14 @@ import src.globalvars
class BenchmarkEspresso(Benchmark):
"""TODO"""
def __init__(self):
- self.name = "espresso"
+ name = "espresso"
self.cmd = "espresso{binary_suffix} {file}"
- self.args = {"file": [os.path.join(src.globalvars.benchsrcdir, self.name,
+ self.args = {"file": [os.path.join(src.globalvars.benchsrcdir, name,
"largest.espresso")]}
- super().__init__()
-
self.requirements = ["espresso"]
+ super().__init__(name)
def summary(self):
# Speed
diff --git a/src/benchmarks/falsesharing.py b/src/benchmarks/falsesharing.py
index 80e8195..5debd94 100644
--- a/src/benchmarks/falsesharing.py
+++ b/src/benchmarks/falsesharing.py
@@ -36,7 +36,7 @@ class BenchmarkFalsesharing(Benchmark):
"""
def __init__(self):
- self.name = "falsesharing"
+ name = "falsesharing"
self.cmd = "cache-{bench}{binary_suffix} {threads} 100 8 1000000"
@@ -44,7 +44,7 @@ class BenchmarkFalsesharing(Benchmark):
"threads": Benchmark.scale_threads_for_cpus(2)}
self.requirements = ["cache-thrash", "cache-scratch"]
- super().__init__()
+ super().__init__(name)
@staticmethod
def process_output(result, stdout, stderr, allocator, perm):
diff --git a/src/benchmarks/httpd.py b/src/benchmarks/httpd.py
index 22824f9..16d3b20 100644
--- a/src/benchmarks/httpd.py
+++ b/src/benchmarks/httpd.py
@@ -26,7 +26,7 @@ class BenchmarkHTTPD(Benchmark):
"""TODO"""
def __init__(self):
- self.name = "httpd"
+ name = "httpd"
self.args = {"nthreads": Benchmark.scale_threads_for_cpus(2),
"site": ["index.html", "index.php"]}
@@ -37,7 +37,7 @@ class BenchmarkHTTPD(Benchmark):
self.requirements = ["nginx", "ab"]
- super().__init__()
+ super().__init__(name)
@staticmethod
def process_output(result, stdout, stderr, allocator, perm):
diff --git a/src/benchmarks/larson.py b/src/benchmarks/larson.py
index 191697f..0e6c91e 100644
--- a/src/benchmarks/larson.py
+++ b/src/benchmarks/larson.py
@@ -33,7 +33,7 @@ class BenchmarkLarson(Benchmark):
"""
def __init__(self):
- self.name = "larson"
+ name = "larson"
# Parameters taken from the paper "Memory Allocation for Long-Running Server
# Applications" from Larson and Krishnan
@@ -43,7 +43,7 @@ class BenchmarkLarson(Benchmark):
"threads": Benchmark.scale_threads_for_cpus(2)}
self.requirements = ["larson"]
- super().__init__()
+ super().__init__(name)
@staticmethod
def process_output(result, stdout, stderr, target, perm):
diff --git a/src/benchmarks/lld.py b/src/benchmarks/lld.py
index d626214..c5c802b 100644
--- a/src/benchmarks/lld.py
+++ b/src/benchmarks/lld.py
@@ -34,7 +34,7 @@ class BenchmarkLld(Benchmark):
"""
def __init__(self):
- self.name = "lld"
+ name = "lld"
self.run_dir = "lld-speed-test/{test}"
# TODO: don't hardcode ld.lld location
@@ -45,7 +45,7 @@ class BenchmarkLld(Benchmark):
"gold-fsds", "llvm-as", "mozilla"]}
self.requirements = ["ld.lld"]
- super().__init__()
+ super().__init__(name)
def prepare(self):
super().prepare()
diff --git a/src/benchmarks/loop.py b/src/benchmarks/loop.py
index f805932..5f016d8 100644
--- a/src/benchmarks/loop.py
+++ b/src/benchmarks/loop.py
@@ -27,7 +27,7 @@ class BenchmarkLoop(Benchmark):
"""
def __init__(self):
- self.name = "loop"
+ name = "loop"
self.cmd = "loop{binary_suffix} {nthreads} 1000000 {maxsize}"
@@ -35,7 +35,7 @@ class BenchmarkLoop(Benchmark):
"nthreads": Benchmark.scale_threads_for_cpus(2)}
self.requirements = ["loop"]
- super().__init__()
+ super().__init__(name)
def summary(self):
# Speed
diff --git a/src/benchmarks/mysql.py b/src/benchmarks/mysql.py
index b21bc0c..28cb982 100644
--- a/src/benchmarks/mysql.py
+++ b/src/benchmarks/mysql.py
@@ -52,7 +52,7 @@ class BenchmarkMYSQL(Benchmark):
"""
def __init__(self):
- self.name = "mysql"
+ name = "mysql"
self.args = {"nthreads": Benchmark.scale_threads_for_cpus(1)}
self.cmd = CMD
@@ -61,7 +61,7 @@ class BenchmarkMYSQL(Benchmark):
self.requirements = ["mysqld", "sysbench"]
- super().__init__()
+ super().__init__(name)
self.results["facts"]["runtime [s]"] = RUN_TIME
self.results["facts"]["sysbench"] = subprocess.run(["sysbench", "--version"],
diff --git a/src/benchmarks/realloc.py b/src/benchmarks/realloc.py
index ad31818..05edba1 100644
--- a/src/benchmarks/realloc.py
+++ b/src/benchmarks/realloc.py
@@ -26,14 +26,12 @@ class BenchmarkRealloc(Benchmark):
realloc a pointer 100 times
"""
def __init__(self):
- self.name = "realloc"
+ name = "realloc"
self.cmd = "realloc"
- self.args = {"oneshot": [1]}
-
self.requirements = ["realloc"]
- super().__init__()
+ super().__init__(name)
def summary(self):
self.barplot_single_arg("{task-clock}",
diff --git a/src/benchmarks/t_test1.py b/src/benchmarks/t_test1.py
index 057c158..5d3c6cc 100644
--- a/src/benchmarks/t_test1.py
+++ b/src/benchmarks/t_test1.py
@@ -27,7 +27,7 @@ class BenchmarkTTest1(Benchmark):
"""
def __init__(self):
- self.name = "t_test1"
+ name = "t_test1"
self.cmd = "t-test1 {nthreads} {nthreads} 1000000 {maxsize}"
@@ -35,7 +35,7 @@ class BenchmarkTTest1(Benchmark):
"nthreads": Benchmark.scale_threads_for_cpus(2)}
self.requirements = ["t-test1"]
- super().__init__()
+ super().__init__(name)
def summary(self):
# mops / per second