summaryrefslogtreecommitdiff
path: root/obbench
diff options
context:
space:
mode:
authorLars Wirzenius <liw@liw.fi>2015-07-16 13:53:14 +0300
committerLars Wirzenius <liw@liw.fi>2015-07-16 13:53:14 +0300
commit6fbe35216f0cec47bf839435e19a31532da83f58 (patch)
treea3fa3abafb4fb37469a82aca12d1f048e0e1adeb /obbench
parent7e4121d3fd1ffdc4e8fd713cea6d4ff34d4b89bd (diff)
downloadobnam-benchmarks-6fbe35216f0cec47bf839435e19a31532da83f58.tar.gz
Generate and backup live data
Diffstat (limited to 'obbench')
-rwxr-xr-xobbench44
1 files changed, 38 insertions, 6 deletions
diff --git a/obbench b/obbench
index 9505003..ffec6b3 100755
--- a/obbench
+++ b/obbench
@@ -44,8 +44,9 @@ class ObnamBenchmarker(cliapp.Application):
def run_all_benchmarks(self, spec, treeish, tempdir):
checkout = self.get_treeish(spec, treeish, tempdir)
+ self.prepare_obnam(checkout)
for benchmark in spec.get('benchmarks', []):
- result = self.run_one_benchmark(benchmark, checkout)
+ result = self.run_one_benchmark(benchmark, tempdir, checkout)
self.save_result(spec, result)
def get_treeish(self, spec, treeish, tempdir):
@@ -56,23 +57,54 @@ class ObnamBenchmarker(cliapp.Application):
cliapp.runcmd(['git', 'clean', '-fdxq'], cwd=checkout)
return checkout
- def run_one_benchmark(self, benchmark, checkout):
+ def prepare_obnam(self, checkout):
+ 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, checkout, result)
+ self.run_benchmark_step(step, checkout, config, live, result)
return result
- def run_benchmark_step(self, step, checkout, result):
- step_info = dict(step)
+ def create_obnam_config(self, spec, tempdir):
+ config = os.path.join(tempdir, 'obnam.conf')
+ with open(config, 'w') as f:
+ f.write('[config]\n')
+ f.write('repository = %s\n' % os.path.join(tempdir, 'repo'))
+ f.write('root = %s\n' % self.get_live_data(tempdir))
+ return config
+
+ def get_live_data(self, tempdir):
+ return os.path.join(tempdir, 'live')
+
+ def create_live_dir(self, tempdir):
+ live = self.get_live_data(tempdir)
+ if os.path.exists(live):
+ shutil.rmtree(live)
+ os.mkdir(live)
+ return live
+
+ def run_benchmark_step(self, step, checkout, config, live, result):
if 'live' in step:
- cliapp.runcmd(['sh', '-euc', step['live']], cwd=checkout)
+ cliapp.runcmd(['sh', '-euc', step['live']], cwd=live)
+
started = time.time()
+ self.run_obnam(checkout, ['backup', '--config', config])
ended = time.time()
+
+ step_info = dict(step)
step_info['duration'] = ended - started
result.add_step(step_info)
+ def run_obnam(self, checkout, args):
+ cliapp.runcmd(
+ ['./obnam', '--no-default-config'] + args,
+ cwd=checkout)
+
def save_result(self, spec, result):
obj = result.as_dict()
pathname = self.get_report_pathname(spec, result)