summaryrefslogtreecommitdiff
path: root/obbench
diff options
context:
space:
mode:
authorLars Wirzenius <liw@liw.fi>2015-07-16 15:28:02 +0300
committerLars Wirzenius <liw@liw.fi>2015-07-16 15:28:02 +0300
commitc3b04868104fe6972fc1dd5bfea1d8e473eb96c9 (patch)
treeb7206ae7e318b35324f301be149433e47a2d0b19 /obbench
parent8bb555f87365f8af9426407491d1bf348bea1149 (diff)
downloadobnam-benchmarks-c3b04868104fe6972fc1dd5bfea1d8e473eb96c9.tar.gz
Improve progress reporting
Diffstat (limited to 'obbench')
-rwxr-xr-xobbench52
1 files changed, 42 insertions, 10 deletions
diff --git a/obbench b/obbench
index ab11104..7c15e05 100755
--- a/obbench
+++ b/obbench
@@ -20,6 +20,7 @@
import glob
import os
import shutil
+import sys
import tempfile
import time
@@ -33,10 +34,18 @@ class ObnamBenchmarker(cliapp.Application):
if not args:
raise cliapp.AppException('Need benchmark spec filename')
spec = self.read_benchmark_spec(args[0])
+ self.logger = IndentedLogger()
+
tempdir = tempfile.mkdtemp()
for treeish in args[1:]:
- self.run_all_benchmarks(spec, treeish, tempdir)
+ self.logger.msg('Benchmarking treeish %s' % treeish)
+ with self.logger:
+ self.run_all_benchmarks(spec, treeish, tempdir)
+
+ self.logger.msg('Generating HTML')
self.generate_html(spec)
+
+ self.logger.msg('Cleaning up')
shutil.rmtree(tempdir)
def read_benchmark_spec(self, filename):
@@ -62,15 +71,19 @@ class ObnamBenchmarker(cliapp.Application):
cliapp.runcmd(['python', 'setup.py', 'build_ext', '-i'], cwd=checkout)
def run_one_benchmark(self, benchmark, tempdir, checkout):
- result = BenchmarkResult()
- result.collect_info_from_spec(benchmark)
- result.collect_info_from_checkout(checkout)
- config = self.create_obnam_config(benchmark, tempdir)
- live = self.create_live_dir(tempdir)
- for step in benchmark.get('steps', []):
- self.run_benchmark_step(
- step, tempdir, checkout, config, live, result)
- return result
+ self.logger.msg('Running benchmark %s' % benchmark['name'])
+ with self.logger:
+ result = BenchmarkResult()
+ result.collect_info_from_spec(benchmark)
+ result.collect_info_from_checkout(checkout)
+
+ config = self.create_obnam_config(benchmark, tempdir)
+
+ live = self.create_live_dir(tempdir)
+ for step in benchmark.get('steps', []):
+ self.run_benchmark_step(
+ step, tempdir, checkout, config, live, result)
+ return result
def create_obnam_config(self, spec, tempdir):
config = os.path.join(tempdir, 'obnam.conf')
@@ -95,9 +108,11 @@ class ObnamBenchmarker(cliapp.Application):
step_info = dict(step)
if 'live' in step:
+ self.logger.msg('Creating live data: %s' % step['live'])
cliapp.runcmd(['sh', '-euc', step['live']], cwd=live)
action = step['obnam']
+ self.logger.msg('Obnam %s' % action)
func = funcs = {
'backup': self.run_backup,
'restore': self.run_restore,
@@ -303,5 +318,22 @@ class BenchmarkResult(object):
return self._dict['commit_id']
+class IndentedLogger(object):
+
+ def __init__(self):
+ self._level = 0
+ self._indent = 2
+
+ def msg(self, text):
+ sys.stdout.write(' ' * (self._level * self._indent))
+ sys.stdout.write(text + '\n')
+ sys.stdout.flush()
+
+ def __enter__(self):
+ self._level += 1
+
+ def __exit__(self, *args):
+ self._level -= 1
+
if __name__ == '__main__':
ObnamBenchmarker().run()