aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFlorian Fischer <florian.fl.fischer@fau.de>2020-07-13 11:03:05 +0200
committerFlorian Fischer <florian.fl.fischer@fau.de>2020-07-13 11:03:05 +0200
commit8ccad6b29c15150e643c2302bd751d16aa294874 (patch)
treeec01e0e05720f4df3259081a6631271950e431fb
parenta2980bb14f909fbba31374bc203c4d530bf3fff0 (diff)
downloadallocbench-8ccad6b29c15150e643c2302bd751d16aa294874.tar.gz
allocbench-8ccad6b29c15150e643c2302bd751d16aa294874.zip
move VERBOSITY from globalvars to util
-rw-r--r--allocbench/globalvars.py4
-rw-r--r--allocbench/util.py17
-rwxr-xr-xbench.py5
3 files changed, 12 insertions, 14 deletions
diff --git a/allocbench/globalvars.py b/allocbench/globalvars.py
index 154a15b..0640dc7 100644
--- a/allocbench/globalvars.py
+++ b/allocbench/globalvars.py
@@ -16,15 +16,11 @@
# along with allocbench. If not, see <http://www.gnu.org/licenses/>.
"""Global variables for allocbench
-VERBOSITY: Verbosity level -1: quiet, 0: status, 1: info, 2: stdout of subcommands, 3: debug info
ALLOCATORS: Dict holding the allocators to compare
-BENCHMARKS: List of available benchmarks
"""
from typing import Dict
from allocbench.allocator import Allocator
-VERBOSITY = 0
-
ALLOCATORS: Dict[str, Allocator] = {}
diff --git a/allocbench/util.py b/allocbench/util.py
index 0063ad4..106c4d9 100644
--- a/allocbench/util.py
+++ b/allocbench/util.py
@@ -21,7 +21,8 @@ import os
import subprocess
import sys
-import allocbench.globalvars
+# Verbosity level -1: quiet, 0: status, 1: info, 2: stdout of subcommands, 3: debug info
+VERBOSITY = 0
def run_cmd(cmd,
@@ -35,7 +36,7 @@ def run_cmd(cmd,
if capture:
stdout = subprocess.PIPE
stderr = stdout
- elif allocbench.globalvars.VERBOSITY < output_verbosity:
+ elif VERBOSITY < output_verbosity:
stdout = subprocess.DEVNULL
stderr = stdout
else:
@@ -98,7 +99,7 @@ def prefix_cmd_with_abspath(cmd):
def allocbench_msg(color, *objects, sep=' ', end='\n', file=None):
"""Colored output function wrapping print"""
- if allocbench.globalvars.VERBOSITY < 0:
+ if VERBOSITY < 0:
return
color = {
@@ -119,28 +120,28 @@ def allocbench_msg(color, *objects, sep=' ', end='\n', file=None):
def print_debug(*objects, sep=' ', end='\n', file=None):
"""Print colorless debug message"""
- if allocbench.globalvars.VERBOSITY < 3:
+ if VERBOSITY < 3:
return
print(*objects, sep=sep, end=end, file=file)
def print_info(*objects, sep=' ', end='\n', file=None):
"""Print colorless info message"""
- if allocbench.globalvars.VERBOSITY < 1:
+ if VERBOSITY < 1:
return
print(*objects, sep=sep, end=end, file=file)
def print_info0(*objects, sep=' ', end='\n', file=None):
"""Print colorless info message at every verbosity level message"""
- if allocbench.globalvars.VERBOSITY < 0:
+ if VERBOSITY < 0:
return
print(*objects, sep=sep, end=end, file=file)
def print_info2(*objects, sep=' ', end='\n', file=None):
"""Print colorless info message at the second verbosity level message"""
- if allocbench.globalvars.VERBOSITY < 2:
+ if VERBOSITY < 2:
return
print(*objects, sep=sep, end=end, file=file)
@@ -152,7 +153,7 @@ def print_status(*objects, sep=' ', end='\n', file=None):
def print_warn(*objects, sep=' ', end='\n', file=None):
"""Print yellow warning"""
- if allocbench.globalvars.VERBOSITY < 1:
+ if VERBOSITY < 1:
return
allocbench_msg("YELLOW", *objects, sep=sep, end=end, file=file)
diff --git a/bench.py b/bench.py
index 925159b..7cb93f8 100755
--- a/bench.py
+++ b/bench.py
@@ -31,6 +31,7 @@ from allocbench.benchmark import get_benchmark_object
from allocbench.directories import get_current_result_dir, set_current_result_dir
import allocbench.facter as facter
import allocbench.globalvars
+import allocbench.util
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
@@ -127,14 +128,14 @@ def main():
# 2: Print all infos
# 3: Print everything
if args.verbose:
- allocbench.globalvars.VERBOSITY = args.verbose
+ allocbench.util.VERBOSITY = args.verbose
print_info2("Arguments:", args)
# Prepare allocbench
print_status("Building allocbench ...")
make_cmd = ["make"]
- if allocbench.globalvars.VERBOSITY < 2:
+ if allocbench.util.VERBOSITY < 2:
make_cmd.append("-s")
run_cmd(make_cmd, output_verbosity=1)