From f097c61b1c1435d4849a33930cb75332dc7158dc Mon Sep 17 00:00:00 2001 From: Lars Wirzenius Date: Fri, 25 Dec 2015 13:06:49 +0100 Subject: Rewrite obbench, adding yarns and Debian packaging --- obbenchlib/result.py | 57 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 57 insertions(+) create mode 100644 obbenchlib/result.py (limited to 'obbenchlib/result.py') diff --git a/obbenchlib/result.py b/obbenchlib/result.py new file mode 100644 index 0000000..8ac24b8 --- /dev/null +++ b/obbenchlib/result.py @@ -0,0 +1,57 @@ +# Copyright 2015 Lars Wirzenius +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . +# +# =*= License: GPL-3+ =*= + + +import os +import random + +import yaml + + +class Result(object): + + def __init__(self): + self.benchmark_name = None + self.run_timestamp = None + self.commit_date = None + self.commit_timestamp = None + self.commit_id = None + self._result_id = random.randint(0, 2**64-1) + self._steps = [] + + def start_step(self): + self._steps.append({}) + + def set_value(self, operation, kind, value): + step = self._steps[-1] + if operation not in step: + step[operation] = {} + step[operation][kind] = value + + def save_in_dir(self, dirname): + o = { + 'result_id': self._result_id, + 'benchmark_name': self.benchmark_name, + 'run_timestamp': self.run_timestamp, + 'commit_date': self.commit_date, + 'commit_timestamp': self.commit_timestamp, + 'commit_id': self.commit_id, + 'steps': self._steps, + } + filename = os.path.join(dirname, '{}.yaml'.format(self._result_id)) + with open(filename, 'w') as f: + yaml.safe_dump(o, stream=f) -- cgit v1.2.1