diff options
| author | Florian Fischer <florian.fl.fischer@fau.de> | 2020-05-10 09:45:24 +0200 |
|---|---|---|
| committer | Florian Fischer <florian.fl.fischer@fau.de> | 2020-06-02 11:18:47 +0200 |
| commit | 184753a6cf10bf24b50b06c66ea2a2ba8bedc6b3 (patch) | |
| tree | a6b1b62b944af32eeff134cd038734d139e389d7 | |
| parent | d5eed692fcd281d942853fbcb5a5685476d326d9 (diff) | |
| download | allocbench-184753a6cf10bf24b50b06c66ea2a2ba8bedc6b3.tar.gz allocbench-184753a6cf10bf24b50b06c66ea2a2ba8bedc6b3.zip | |
make benchmark definitions more pythonic
Don't export a singleton object in the definiton.
An object is now created when the Benchmark should be executed, thus
we don't need a prepare method this can be done in __init__
| -rw-r--r-- | allocbench/benchmarks/blowup.py | 3 | ||||
| -rw-r--r-- | allocbench/benchmarks/cfrac.py | 3 | ||||
| -rw-r--r-- | allocbench/benchmarks/dj_trace.py | 6 | ||||
| -rw-r--r-- | allocbench/benchmarks/espresso.py | 3 | ||||
| -rw-r--r-- | allocbench/benchmarks/falsesharing.py | 11 | ||||
| -rw-r--r-- | allocbench/benchmarks/fd.py | 9 | ||||
| -rw-r--r-- | allocbench/benchmarks/httpd.py | 6 | ||||
| -rw-r--r-- | allocbench/benchmarks/keydb.py | 6 | ||||
| -rw-r--r-- | allocbench/benchmarks/larson.py | 3 | ||||
| -rw-r--r-- | allocbench/benchmarks/lld.py | 6 | ||||
| -rw-r--r-- | allocbench/benchmarks/loop.py | 3 | ||||
| -rw-r--r-- | allocbench/benchmarks/mysql.py | 18 | ||||
| -rw-r--r-- | allocbench/benchmarks/raxmlng.py | 6 | ||||
| -rw-r--r-- | allocbench/benchmarks/rdtsc.py | 4 | ||||
| -rw-r--r-- | allocbench/benchmarks/realloc.py | 3 | ||||
| -rw-r--r-- | allocbench/benchmarks/redis.py | 6 | ||||
| -rw-r--r-- | allocbench/benchmarks/t_test1.py | 3 | ||||
| -rwxr-xr-x | bench.py | 29 |
18 files changed, 26 insertions, 102 deletions
diff --git a/allocbench/benchmarks/blowup.py b/allocbench/benchmarks/blowup.py index c4d5b5b..8f61421 100644 --- a/allocbench/benchmarks/blowup.py +++ b/allocbench/benchmarks/blowup.py @@ -77,6 +77,3 @@ class BenchmarkBlowup(Benchmark): del self.results["stats"]["Ideal-RSS"] # plt.export_stats_to_dataref(self, "VmHWM") - - -blowup = BenchmarkBlowup() diff --git a/allocbench/benchmarks/cfrac.py b/allocbench/benchmarks/cfrac.py index 9a2628a..08e3583 100644 --- a/allocbench/benchmarks/cfrac.py +++ b/allocbench/benchmarks/cfrac.py @@ -120,6 +120,3 @@ class BenchmarkCfrac(Benchmark): plt.export_stats_to_dataref(self, "task-clock") plt.export_stats_to_dataref(self, "VmHWM") - - -cfrac = BenchmarkCfrac() diff --git a/allocbench/benchmarks/dj_trace.py b/allocbench/benchmarks/dj_trace.py index 39ab5d4..d24a2b5 100644 --- a/allocbench/benchmarks/dj_trace.py +++ b/allocbench/benchmarks/dj_trace.py @@ -131,9 +131,6 @@ class BenchmarkDJTrace(Benchmark): self.requirements = ["trace_run"] super().__init__(name) - def prepare(self): - super().prepare() - workloads = ArchiveArtifact( "dj_workloads", "https://www4.cs.fau.de/~flow/allocbench/dj_workloads.tar.xz", @@ -451,6 +448,3 @@ class BenchmarkDJTrace(Benchmark): tmeans[3], np.mean(rss_change_means)), '\n', file=summary_file) - - -dj_trace = BenchmarkDJTrace() diff --git a/allocbench/benchmarks/espresso.py b/allocbench/benchmarks/espresso.py index 6be9ce4..0b9b852 100644 --- a/allocbench/benchmarks/espresso.py +++ b/allocbench/benchmarks/espresso.py @@ -120,6 +120,3 @@ class BenchmarkEspresso(Benchmark): plt.export_stats_to_dataref(self, "task-clock") plt.export_stats_to_dataref(self, "VmHWM") - - -espresso = BenchmarkEspresso() diff --git a/allocbench/benchmarks/falsesharing.py b/allocbench/benchmarks/falsesharing.py index 1fd4931..423dd9d 100644 --- a/allocbench/benchmarks/falsesharing.py +++ b/allocbench/benchmarks/falsesharing.py @@ -67,8 +67,8 @@ class BenchmarkFalsesharing(Benchmark): measure["speedup"] = sequential_time / float( measure["time"]) measure["l1chache_misses"] = ( - measure['L1-dcache-load-misses'] / - measure['L1-dcache-loads']) * 100 + float(measure['L1-dcache-load-misses']) / + float(measure['L1-dcache-loads'])) * 100 # delete and recalculate stats del self.results["stats"] @@ -79,7 +79,7 @@ class BenchmarkFalsesharing(Benchmark): x_args=["bench"], fig_options={ 'ylabel': "Speedup", - 'title': "Speedup: {arg} {arg_value}", + 'title': "Speedup: {fixed_part_str}", 'autoticks': False, }, file_postfix="speedup") @@ -89,7 +89,7 @@ class BenchmarkFalsesharing(Benchmark): x_args=["bench"], fig_options={ 'ylabel': "l1 cache misses in %", - 'title': "cache misses: {arg} {arg_value}", + 'title': "cache misses: {fixed_part_str}", 'autoticks': False, }, file_postfix="l1-misses") @@ -117,6 +117,3 @@ class BenchmarkFalsesharing(Benchmark): # create pgfplot legend plt.pgfplot_legend(self) - - -falsesharing = BenchmarkFalsesharing() diff --git a/allocbench/benchmarks/fd.py b/allocbench/benchmarks/fd.py index eccd41f..300359d 100644 --- a/allocbench/benchmarks/fd.py +++ b/allocbench/benchmarks/fd.py @@ -28,12 +28,8 @@ class BenchmarkFd(Benchmark): """ def __init__(self): name = "fd" - super().__init__(name) - self.cmd = "fd -HI -e c '.*[0-9].*' {linux_files}" - - def prepare(self): - super().prepare() + super().__init__(name) linux = GitArtifact( "linux", @@ -85,6 +81,3 @@ class BenchmarkFd(Benchmark): file_postfix="memusage") plt.export_stats_to_dataref(self, "VmHWM") - - -fd = BenchmarkFd() diff --git a/allocbench/benchmarks/httpd.py b/allocbench/benchmarks/httpd.py index df63919..a601612 100644 --- a/allocbench/benchmarks/httpd.py +++ b/allocbench/benchmarks/httpd.py @@ -44,9 +44,6 @@ class BenchmarkHTTPD(Benchmark): super().__init__(name) - def prepare(self): - super().prepare() - self.results["facts"]["versions"]["nginx"] = facter.exe_version( "nginx", "-v") self.results["facts"]["versions"]["ab"] = facter.exe_version( @@ -89,6 +86,3 @@ class BenchmarkHTTPD(Benchmark): 'autoticks': False, }, file_postfix="php-fpm_vmhwm") - - -httpd = BenchmarkHTTPD() diff --git a/allocbench/benchmarks/keydb.py b/allocbench/benchmarks/keydb.py index 49ba211..1cb6e64 100644 --- a/allocbench/benchmarks/keydb.py +++ b/allocbench/benchmarks/keydb.py @@ -48,9 +48,6 @@ class BenchmarkKeyDB(Benchmark): super().__init__(name) - def prepare(self): - super().prepare() - keydb_version = "v5.3.1" self.results["facts"]["versions"]["keydb"] = keydb_version keydb_dir = os.path.join(self.build_dir, "keydb") @@ -127,6 +124,3 @@ class BenchmarkKeyDB(Benchmark): 'title': "KeyDB Memusage - {fixed_part_str}", }, file_postfix="vmhwm") - - -keydb = BenchmarkKeyDB() diff --git a/allocbench/benchmarks/larson.py b/allocbench/benchmarks/larson.py index f416b4f..cc78be7 100644 --- a/allocbench/benchmarks/larson.py +++ b/allocbench/benchmarks/larson.py @@ -96,6 +96,3 @@ class BenchmarkLarson(Benchmark): 'title': "Larson cache misses: {fixed_part_str}", }, file_postfix="cachemisses") - - -larson = BenchmarkLarson() diff --git a/allocbench/benchmarks/lld.py b/allocbench/benchmarks/lld.py index f89c27e..80bc5c2 100644 --- a/allocbench/benchmarks/lld.py +++ b/allocbench/benchmarks/lld.py @@ -230,9 +230,6 @@ class BenchmarkLld(Benchmark): self.requirements = ["ld.lld"] super().__init__(name) - def prepare(self): - super().prepare() - # save lld version self.results["facts"]["versions"]["lld"] = facter.exe_version( "ld.lld", "-v") @@ -295,6 +292,3 @@ class BenchmarkLld(Benchmark): "sort": "<" }], file_postfix="table") - - -lld = BenchmarkLld() diff --git a/allocbench/benchmarks/loop.py b/allocbench/benchmarks/loop.py index 6a08ea8..1c22da8 100644 --- a/allocbench/benchmarks/loop.py +++ b/allocbench/benchmarks/loop.py @@ -113,6 +113,3 @@ class BenchmarkLoop(Benchmark): # create pgfplot legend plt.pgfplot_legend(self) - - -loop = BenchmarkLoop() diff --git a/allocbench/benchmarks/mysql.py b/allocbench/benchmarks/mysql.py index f8f6d60..111d482 100644 --- a/allocbench/benchmarks/mysql.py +++ b/allocbench/benchmarks/mysql.py @@ -121,15 +121,6 @@ class BenchmarkMYSQL(Benchmark): self.results["facts"]["runtime [s]"] = RUN_TIME - def reset_preparations(self): - """Reset self.build_dir if preparing fails""" - if os.path.exists(self.build_dir): - print_warn("Reset mysql test directory") - shutil.rmtree(self.build_dir, ignore_errors=True) - - def prepare(self): - super().prepare() - # save mysqld and sysbench versions for exe in self.requirements: self.results["facts"]["versions"][exe] = facter.exe_version( @@ -187,6 +178,12 @@ class BenchmarkMYSQL(Benchmark): self.shutdown_servers() + def reset_preparations(self): + """Reset self.build_dir if preparing fails""" + if os.path.exists(self.build_dir): + print_warn("Reset mysql test directory") + shutil.rmtree(self.build_dir, ignore_errors=True) + @staticmethod def process_output(result, stdout, stderr, allocator, perm): # pylint: disable=too-many-arguments, unused-argument result["transactions"] = re.search("transactions:\\s*(\\d*)", @@ -321,6 +318,3 @@ class BenchmarkMYSQL(Benchmark): plt.export_stats_to_csv(self, "transactions") plt.export_stats_to_dataref(self, "transactions") - - -mysql = BenchmarkMYSQL() diff --git a/allocbench/benchmarks/raxmlng.py b/allocbench/benchmarks/raxmlng.py index 65a4838..b943e4e 100644 --- a/allocbench/benchmarks/raxmlng.py +++ b/allocbench/benchmarks/raxmlng.py @@ -39,9 +39,6 @@ class BenchmarkRaxmlng(Benchmark): f"raxml-ng --msa {self.build_dir}/data/prim.phy --model GTR+G" " --redo --threads 2 --seed 2") - def prepare(self): - super().prepare() - if os.path.exists(self.build_dir): return @@ -104,6 +101,3 @@ class BenchmarkRaxmlng(Benchmark): file_postfix="memusage") plt.export_stats_to_dataref(self, "VmHWM") - - -raxmlng = BenchmarkRaxmlng() diff --git a/allocbench/benchmarks/rdtsc.py b/allocbench/benchmarks/rdtsc.py index 6b3bf60..0600f4c 100644 --- a/allocbench/benchmarks/rdtsc.py +++ b/allocbench/benchmarks/rdtsc.py @@ -72,9 +72,5 @@ class BenchmarkRdtsc(Benchmark): plt.legend() plt.title(str(perm)) fig.savefig(f'{label}.{SUMMARY_FILE_EXT}') - plt.show() allocbench.plots.export_stats_to_csv(self, "cycles") - - -rdtsc = BenchmarkRdtsc() diff --git a/allocbench/benchmarks/realloc.py b/allocbench/benchmarks/realloc.py index bfd285b..b1f699e 100644 --- a/allocbench/benchmarks/realloc.py +++ b/allocbench/benchmarks/realloc.py @@ -45,6 +45,3 @@ class BenchmarkRealloc(Benchmark): plt.export_stats_to_csv(self, "task-clock") plt.export_stats_to_dataref(self, "task-clock") - - -realloc = BenchmarkRealloc() diff --git a/allocbench/benchmarks/redis.py b/allocbench/benchmarks/redis.py index 4fd8fb1..8db69c3 100644 --- a/allocbench/benchmarks/redis.py +++ b/allocbench/benchmarks/redis.py @@ -47,9 +47,6 @@ class BenchmarkRedis(Benchmark): super().__init__(name) - def prepare(self): - super().prepare() - redis_version = "5.0.5" self.results["facts"]["versions"]["redis"] = redis_version redis_artifact = ArchiveArtifact( @@ -100,6 +97,3 @@ class BenchmarkRedis(Benchmark): file_postfix="vmhwm") plt.export_stats_to_dataref(self, "requests") - - -redis = BenchmarkRedis() diff --git a/allocbench/benchmarks/t_test1.py b/allocbench/benchmarks/t_test1.py index 4ddf940..b6b7cf4 100644 --- a/allocbench/benchmarks/t_test1.py +++ b/allocbench/benchmarks/t_test1.py @@ -74,6 +74,3 @@ class BenchmarkTTest1(Benchmark): file_postfix="mops.table") plt.export_stats_to_csv(self, "task-clock") - - -t_test1 = BenchmarkTTest1() @@ -30,7 +30,7 @@ from allocbench.allocator import collect_allocators from allocbench.analyse import analyze_bench, analyze_allocators import allocbench.facter as facter import allocbench.globalvars -from allocbench.util import find_cmd, run_cmd +from allocbench.util import run_cmd from allocbench.util import print_status, print_warn, print_error from allocbench.util import print_info, print_info2, print_debug from allocbench.util import print_license_and_exit @@ -176,20 +176,21 @@ def main(): bench_module = importlib.import_module( f"allocbench.benchmarks.{bench}") - if not hasattr(bench_module, bench): - print_error(f"{bench_module} has no member {bench}.") - print_error(f"Skipping {bench_module}") - continue - - bench = getattr(bench_module, bench) + # find Benchmark class + for member in bench_module.__dict__.values(): + if (isinstance(member, type) + or member is allocbench.benchmark.Benchmark + or not issubclass(member, allocbench.benchmark.Benchmark)): + continue - print_status("Preparing", bench.name, "...") - try: - bench.prepare() - except Exception: - print_error(traceback.format_exc()) - print_error(f"Skipping {bench}! Preparing failed.") - continue + try: + print_status("Preparing", bench, "...") + bench = member() + break + except Exception: + print_error(traceback.format_exc()) + print_error(f"Skipping {bench}! Preparing failed.") + continue if args.analyze: analyze_bench(bench) |
