aboutsummaryrefslogtreecommitdiff
path: root/src/benchmark.py
diff options
context:
space:
mode:
authorFlorian Fischer <florian.fl.fischer@fau.de>2019-02-22 17:42:51 +0100
committerFlorian Fischer <florian.fl.fischer@fau.de>2019-02-22 17:42:51 +0100
commit8fb74f194f33e1824fab9bea2286d45e38d8c375 (patch)
tree24c0cf38ea94972d98b51591c3b4e96b67ab6c97 /src/benchmark.py
parent294ed02cd6e3c35c6981fa5fe5070b29a7b77484 (diff)
downloadallocbench-8fb74f194f33e1824fab9bea2286d45e38d8c375.tar.gz
allocbench-8fb74f194f33e1824fab9bea2286d45e38d8c375.zip
add perf check
Diffstat (limited to 'src/benchmark.py')
-rw-r--r--src/benchmark.py19
1 files changed, 19 insertions, 0 deletions
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")