diff options
| author | Florian Fischer <florian.fl.fischer@fau.de> | 2019-08-12 21:05:41 +0200 |
|---|---|---|
| committer | Florian Fischer <florian.fl.fischer@fau.de> | 2019-08-12 21:05:41 +0200 |
| commit | 9def09b57ae59593791fb577049bb7600175120b (patch) | |
| tree | 27c6864508f6e225194e29c3b4b442d5bb5f388e | |
| parent | b9fa969cc2d56ee0e3d170e2b6f8cca3e7e333f1 (diff) | |
| download | allocbench-9def09b57ae59593791fb577049bb7600175120b.tar.gz allocbench-9def09b57ae59593791fb577049bb7600175120b.zip | |
use logging in mysql benchmarklogging
| -rw-r--r-- | src/benchmarks/mysql.py | 25 |
1 files changed, 13 insertions, 12 deletions
diff --git a/src/benchmarks/mysql.py b/src/benchmarks/mysql.py index 47d884f..01f10e0 100644 --- a/src/benchmarks/mysql.py +++ b/src/benchmarks/mysql.py @@ -1,5 +1,6 @@ import multiprocessing import numpy as np +import logging import os import re import shutil @@ -9,7 +10,6 @@ import sys from src.globalvars import allocators from src.benchmark import Benchmark -from src.util import print_status, print_debug, print_info2 cwd = os.getcwd() @@ -24,6 +24,7 @@ cmd = ("sysbench oltp_read_only --threads={nthreads} --time=10 --tables=5 " server_cmd = ("mysqld --no-defaults -h {0}/mysql_test --socket={0}/mysql_test/socket --port=123456 " "--max-connections={1} --secure-file-priv=").format(cwd, multiprocessing.cpu_count()) +logger = logging.getLogger("allocbench.src.benchmarks.mysql") class Benchmark_MYSQL(Benchmark): def __init__(self): @@ -44,7 +45,7 @@ class Benchmark_MYSQL(Benchmark): # Setup Test Environment if not os.path.exists("mysql_test"): - print_status("Prepare mysqld directory and database") + logger.status("Prepare mysqld directory and database") os.makedirs("mysql_test") # Init database @@ -53,18 +54,18 @@ class Benchmark_MYSQL(Benchmark): if b"MariaDB" in self.results["facts"]["mysqld"]: init_db_cmd = ["mysql_install_db", "--basedir=/usr", "--datadir="+cwd+"/mysql_test"] - print_info2("MariaDB detected") + logger.info("MariaDB detected") else: init_db_cmd = ["mysqld", "-h", cwd+"/mysql_test", "--initialize-insecure"] - print_info2("Oracle MySQL detected") + logger.info("Oracle MySQL detected") p = subprocess.run(init_db_cmd, stdout=PIPE, stderr=PIPE) if not p.returncode == 0: - print_debug(init_db_cmd) - print_debug("Stdout:", p.stdout, file=sys.stdout) - print_debug("Stderr:", p.stderr, file=sys.stderr) + logger.debug(init_db_cmd) + logger.debug("Stdout:", p.stdout, file=sys.stdout) + logger.debug("Stderr:", p.stderr, file=sys.stderr) raise Exception("Creating test DB failed with:", p.returncode) self.start_servers() @@ -75,22 +76,22 @@ class Benchmark_MYSQL(Benchmark): stdout=PIPE, stderr=PIPE) if p.returncode != 0: - print_debug("Stderr:", p.stderr, file=sys.stderr) + logger.debug("Stderr:", p.stderr, file=sys.stderr) raise Exception("Creating test tables failed with:", p.returncode) - print_status("Prepare test tables ...") + logger.status("Prepare test tables ...") ret = True p = subprocess.run(prepare_cmd, stdout=PIPE, stderr=PIPE) if p.returncode != 0: - print_debug("Stdout:", p.stdout, file=sys.stderr) - print_debug("Stderr:", p.stderr, file=sys.stderr) + logger.debug("Stdout:", p.stdout, file=sys.stderr) + logger.debug("Stderr:", p.stderr, file=sys.stderr) raise Exception("Preparing test tables failed with:", p.returncode) self.shutdown_servers() def cleanup(self): if os.path.exists("mysql_test"): - print_status("Delete mysqld directory") + logger.status("Delete mysqld directory") shutil.rmtree("mysql_test", ignore_errors=True) def process_output(self, result, stdout, stderr, allocator, perm, verbose): |
