From 383df3e024a52b6152ae33ae122ec977ac53cec0 Mon Sep 17 00:00:00 2001 From: Florian Fischer Date: Sun, 28 Apr 2019 22:54:12 +0200 Subject: start moving allocator definitions to src/allocators --- bench.py | 2 +- src/allocators.py | 27 --------------------------- src/allocators/installed_allocators.py | 27 +++++++++++++++++++++++++++ 3 files changed, 28 insertions(+), 28 deletions(-) delete mode 100644 src/allocators.py create mode 100644 src/allocators/installed_allocators.py diff --git a/bench.py b/bench.py index 023614e..685ff80 100755 --- a/bench.py +++ b/bench.py @@ -102,7 +102,7 @@ def main(): else: print_status("Using system-wide installed allocators ...") # Normal import fails - importlib.import_module('src.allocators') + importlib.import_module('src.allocators.installed_allocators') print_info("Allocators:", *src.globalvars.allocators.keys()) diff --git a/src/allocators.py b/src/allocators.py deleted file mode 100644 index 26fab5b..0000000 --- a/src/allocators.py +++ /dev/null @@ -1,27 +0,0 @@ -"""Default allocators using system libraries""" - -import os -import subprocess - -import src.globalvars - -maybe_allocators = ["tcmalloc", "jemalloc", "hoard"] - -src.globalvars.allocators = {"libc": {"cmd_prefix" : "", - "binary_suffix" : "", - "LD_PRELOAD" : "", - "color" : "C1"}} - -for i, t in enumerate(maybe_allocators): - try: - path = subprocess.run('whereis lib{} | cut -d":" -f2'.format(t), - shell=True, stdout=subprocess.PIPE, - universal_newlines=True).stdout.strip() - - if path != "": - src.globalvars.allocators[t] = {"cmd_prefix": "", - "binary_suffix": "", - "LD_PRELOAD": path, - "color": "C"+str(i+2)} - except: - pass diff --git a/src/allocators/installed_allocators.py b/src/allocators/installed_allocators.py new file mode 100644 index 0000000..26fab5b --- /dev/null +++ b/src/allocators/installed_allocators.py @@ -0,0 +1,27 @@ +"""Default allocators using system libraries""" + +import os +import subprocess + +import src.globalvars + +maybe_allocators = ["tcmalloc", "jemalloc", "hoard"] + +src.globalvars.allocators = {"libc": {"cmd_prefix" : "", + "binary_suffix" : "", + "LD_PRELOAD" : "", + "color" : "C1"}} + +for i, t in enumerate(maybe_allocators): + try: + path = subprocess.run('whereis lib{} | cut -d":" -f2'.format(t), + shell=True, stdout=subprocess.PIPE, + universal_newlines=True).stdout.strip() + + if path != "": + src.globalvars.allocators[t] = {"cmd_prefix": "", + "binary_suffix": "", + "LD_PRELOAD": path, + "color": "C"+str(i+2)} + except: + pass -- cgit v1.2.3