mirror of
https://github.com/tahoe-lafs/tahoe-lafs.git
synced 2025-01-11 23:42:38 +00:00
change data format; append to old results
This commit is contained in:
parent
e104504a36
commit
b5d4a710fe
@ -7,6 +7,7 @@ to pytest.
|
|||||||
|
|
||||||
import os
|
import os
|
||||||
import json
|
import json
|
||||||
|
from datetime import datetime, timezone
|
||||||
from shutil import which, rmtree
|
from shutil import which, rmtree
|
||||||
from tempfile import mkdtemp
|
from tempfile import mkdtemp
|
||||||
from contextlib import contextmanager
|
from contextlib import contextmanager
|
||||||
@ -183,12 +184,18 @@ class Benchmarker:
|
|||||||
f"\nBENCHMARK RESULT: {name} {parameters} elapsed={elapsed:.3} (secs) CPU={elapsed_cpu:.3} (secs)\n"
|
f"\nBENCHMARK RESULT: {name} {parameters} elapsed={elapsed:.3} (secs) CPU={elapsed_cpu:.3} (secs)\n"
|
||||||
)
|
)
|
||||||
|
|
||||||
def output_results(self, filelike):
|
def output_results(self, filelike, previous_results=None):
|
||||||
js = dict()
|
results = dict()
|
||||||
for b in self.benchmarks.values():
|
for b in self.benchmarks.values():
|
||||||
js[b.name] = b.to_json()
|
results[b.name] = b.to_json()
|
||||||
|
|
||||||
|
benchmarks = previous_results or []
|
||||||
|
benchmarks.append({
|
||||||
|
"timestamp-utc": datetime.now(timezone.utc).isoformat(),
|
||||||
|
"results": results,
|
||||||
|
})
|
||||||
filelike.write(
|
filelike.write(
|
||||||
json.dumps(js, indent=4).encode("utf8")
|
json.dumps({"benchmarks": benchmarks}, indent=4).encode("utf8")
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
@ -198,5 +205,13 @@ def tahoe_benchmarker(request):
|
|||||||
yield bm
|
yield bm
|
||||||
fname = request.config.getoption("json_fname")
|
fname = request.config.getoption("json_fname")
|
||||||
print(f'Writing benchmarks to "{fname}"')
|
print(f'Writing benchmarks to "{fname}"')
|
||||||
|
try:
|
||||||
|
with open(fname, "rb") as js_file:
|
||||||
|
previous = json.loads(js_file.read())["benchmarks"]
|
||||||
|
except json.decoder.JSONDecodeError as e:
|
||||||
|
print(f"Failed to load previous results: {e}")
|
||||||
|
previous = None
|
||||||
|
except OSError:
|
||||||
|
previous = None
|
||||||
with open(fname, "wb") as js_file:
|
with open(fname, "wb") as js_file:
|
||||||
bm.output_results(js_file)
|
bm.output_results(js_file, previous)
|
||||||
|
Loading…
Reference in New Issue
Block a user