From 8fb74f194f33e1824fab9bea2286d45e38d8c375 Mon Sep 17 00:00:00 2001 From: Florian Fischer Date: Fri, 22 Feb 2019 17:42:51 +0100 Subject: add perf check --- src/benchmark.py | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/src/benchmark.py b/src/benchmark.py index c01a41a..4a23ecf 100644 --- a/src/benchmark.py +++ b/src/benchmark.py @@ -13,6 +13,8 @@ from src.allocators import allocators class Benchmark (object): + perf_allowed = None + defaults = { "name": "default_benchmark", "description": ("This is the default benchmark description please add" @@ -132,6 +134,23 @@ class Benchmark (object): def run(self, runs=5, verbose=False): if runs > 0: print("Running", self.name, "...") + + # check if perf is allowed on this system + if self.measure_cmd == self.defaults["measure_cmd"]: + if perf_allowed == None: + res = subprocess.run(["perf", "stat", "ls"], + stdout=None, stderr=subprocess.PIPE, + universal_newlines=True) + if res.returncode != 0: + print("Test perf run failed with:") + print(res.stderr) + perf_allowed = False + + if not perf_allowed: + print("Skipping", self.name, "because you don't have the", + "needed permissions to use perf") + return False + n = len(list(self.iterate_args())) * len(self.allocators) for run in range(1, runs + 1): print(str(run) + ". run") -- cgit v1.2.3