aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFlorian Fischer <florian.fl.fischer@fau.de>2019-03-05 16:03:42 +0100
committerFlorian Fischer <florian.fl.fischer@fau.de>2019-03-05 16:03:42 +0100
commit89a316bb41077f97f7c79c3568abd90eed6e8fc4 (patch)
tree9fef81b4f927952dd196304b3d44db875fbd185e
parent569f4af9656e1f56b84fb0c3fbbeebd5b6bf9714 (diff)
downloadallocbench-89a316bb41077f97f7c79c3568abd90eed6e8fc4.tar.gz
allocbench-89a316bb41077f97f7c79c3568abd90eed6e8fc4.zip
use new verbosity system in mysql and dj_trace benchmarks
-rw-r--r--src/dj_trace.py6
-rw-r--r--src/mysql.py56
2 files changed, 31 insertions, 31 deletions
diff --git a/src/dj_trace.py b/src/dj_trace.py
index f16fb42..f8d45e8 100644
--- a/src/dj_trace.py
+++ b/src/dj_trace.py
@@ -83,8 +83,8 @@ class Benchmark_DJ_Trace(Benchmark):
self.requirements = ["trace_run"]
super().__init__()
- def prepare(self, verbose=False):
- super().prepare(verbose=verbose)
+ def prepare(self):
+ super().prepare()
def reporthook(blocknum, blocksize, totalsize):
readsofar = blocknum * blocksize
@@ -117,7 +117,7 @@ class Benchmark_DJ_Trace(Benchmark):
continue
if download_all:
- print("downloading {} ({}) ...".format(wl, wl_sizes[wl]))
+ print_status("downloading {} ({}) ...".format(wl, wl_sizes[wl]))
url = "http://www.delorie.com/malloc/" + file_name
urlretrieve(url, file_path, reporthook)
diff --git a/src/mysql.py b/src/mysql.py
index d3eb528..2f0bce5 100644
--- a/src/mysql.py
+++ b/src/mysql.py
@@ -6,10 +6,12 @@ import re
import shutil
import subprocess
from subprocess import PIPE
+import sys
from time import sleep
-from src.benchmark import Benchmark
from src.allocators import allocators
+from src.benchmark import Benchmark
+from src.util import *
cwd = os.getcwd()
@@ -42,25 +44,22 @@ class Benchmark_MYSQL(Benchmark):
self.requirements = ["mysqld", "sysbench"]
super().__init__()
- def start_and_wait_for_server(self, verbose, cmd_prefix=""):
+ def start_and_wait_for_server(self, cmd_prefix=""):
actual_cmd = cmd_prefix.split() + server_cmd
- if verbose:
- print("Starting server with:", actual_cmd)
+ print_info("Starting server with:", actual_cmd)
- self.server = subprocess.Popen(actual_cmd,
- stdout=subprocess.PIPE,
- stderr=subprocess.PIPE,
+ self.server = subprocess.Popen(actual_cmd, stdout=PIPE, stderr=PIPE,
universal_newlines=True)
# TODO make sure server comes up !
sleep(10)
return self.server.poll() is None
- def prepare(self, verbose=False):
- if not super().prepare(verbose=verbose):
+ def prepare(self):
+ if not super().prepare():
return False
# Setup Test Environment
if not os.path.exists("mysql_test"):
- print("Prepare mysqld directory and database")
+ print_status("Prepare mysqld directory and database")
os.makedirs("mysql_test")
# Init database
@@ -68,22 +67,22 @@ class Benchmark_MYSQL(Benchmark):
stdout=PIPE).stdout:
init_db_cmd = ["mysql_install_db", "--basedir=/usr",
"--datadir="+cwd+"/mysql_test"]
- if verbose:
- print("MariaDB detected")
+ print_info2("MariaDB detected")
else:
init_db_cmd = ["mysqld", "-h", cwd+"/mysql_test",
"--initialize-insecure"]
- if verbose:
- print("Oracle MySQL detected")
+ print_info2("Oracle MySQL detected")
p = subprocess.run(init_db_cmd, stdout=PIPE, stderr=PIPE)
if not p.returncode == 0:
- print(p.stderr)
+ print_error("Creating test DB failed with:", p.returncode)
+ print_debug(p.stderr, file=sys.stderr)
return False
- if not self.start_and_wait_for_server(verbose):
- print("Starting mysqld failed")
+ if not self.start_and_wait_for_server():
+ print_error("Starting mysqld failed")
+ print_debug(self.server.stderr, file=sys.stderr)
return False
# Create sbtest TABLE
@@ -92,17 +91,19 @@ class Benchmark_MYSQL(Benchmark):
stdout=PIPE, stderr=PIPE)
if not p.returncode == 0:
- print(p.stderr)
+ print_error("Creating test table failed with:", p.returncode)
+ print_debug(p.stderr, file=sys.stderr)
self.server.kill()
self.server.wait()
return False
- print("Prepare test tables")
+ print_status("Prepare test tables ...")
ret = True
p = subprocess.run(prepare_cmd, stdout=PIPE, stderr=PIPE)
if p.returncode != 0:
- print(p.stdout)
- print(p.stderr)
+ print_error("Preparing test tables failed with:", p.returncode)
+ print_debug(p.stdout, file=sys.stderr)
+ print_debug(p.stderr, file=sys.stderr)
ret = False
self.server.kill()
@@ -114,16 +115,15 @@ class Benchmark_MYSQL(Benchmark):
def cleanup(self):
if os.path.exists("mysql_test"):
- print("Delete mysqld directory")
+ print_status("Delete mysqld directory")
shutil.rmtree("mysql_test")
def preallocator_hook(self, allocator, run, verbose):
- if not self.start_and_wait_for_server(verbose,
- cmd_prefix=allocator[1]["cmd_prefix"]):
- print("Can't start server for", allocator[0] + ".")
- print("Aborting Benchmark.")
- print(allocator[1]["cmd_prefix"])
- print(self.server.stderr.read())
+ if not self.start_and_wait_for_server(cmd_prefix=allocator[1]["cmd_prefix"]):
+ print_error("Can't start server for", allocator[0] + ".")
+ print_error("Aborting Benchmark.")
+ print_debug(allocator[1]["cmd_prefix"], file=sys.stderr)
+ print_debug(self.server.stderr, file=sys.stderr)
return False
def postallocator_hook(self, allocator, run, verbose):