Skip to content

Commit 3e39f53

Browse files
committed
Split and delete runner.py
1 parent 85f7bd5 commit 3e39f53

File tree

5 files changed

+87
-93
lines changed

5 files changed

+87
-93
lines changed

dpbench/console/report.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,7 @@ def execute_report(args: Namespace, conn: sqlalchemy.Engine):
4545
)
4646

4747
import dpbench.config as cfg
48-
from dpbench.infrastructure.reporter import update_run_id
49-
from dpbench.infrastructure.runner import print_report
48+
from dpbench.infrastructure.reporter import print_report, update_run_id
5049

5150
cfg.GLOBAL = cfg.read_configs(
5251
benchmarks=args.benchmarks,

dpbench/infrastructure/benchmark_results.py

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,3 +95,45 @@ def Result(self, run_id: int, benchmark_name, framework_version) -> Result:
9595
if self.validation_state == ValidationStatusCodes.SUCCESS
9696
else "Fail",
9797
)
98+
99+
def _format_ns(self, time_in_ns: int):
100+
time = int(time_in_ns)
101+
assert time >= 0
102+
suff = [
103+
("s", 1000_000_000),
104+
("ms", 1000_000),
105+
("\u03BCs", 1000),
106+
("ns", 0),
107+
]
108+
for s, scale in suff:
109+
if time >= scale:
110+
scaled_time = float(time) / scale if scale > 0 else time
111+
return f"{scaled_time}{s} ({time} ns)"
112+
113+
def print(self, framework_name: str = "", framework_version: str = ""):
114+
print(
115+
"================ implementation "
116+
+ self.impl_postfix
117+
+ " ========================\n"
118+
+ "implementation:",
119+
self.impl_postfix,
120+
)
121+
122+
if self.error_state == ErrorCodes.SUCCESS:
123+
print("framework:", framework_name)
124+
print("framework version:", framework_version)
125+
print("setup time:", self._format_ns(self.setup_time))
126+
print("warmup time:", self._format_ns(self.warmup_time))
127+
print("teardown time:", self._format_ns(self.teardown_time))
128+
print("max execution times:", self._format_ns(self.max_exec_time))
129+
print("min execution times:", self._format_ns(self.min_exec_time))
130+
print(
131+
"median execution times:",
132+
self._format_ns(self.median_exec_time),
133+
)
134+
print("repeats:", self.repeats)
135+
print("preset:", self.preset)
136+
print("validated:", self.validation_state)
137+
else:
138+
print("error states:", self.error_state)
139+
print("error msg:", self.error_msg)

dpbench/infrastructure/benchmark_runner.py

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@
2020
from dpbench.infrastructure.enums import ErrorCodes, ValidationStatusCodes
2121
from dpbench.infrastructure.frameworks import Framework
2222
from dpbench.infrastructure.frameworks.fabric import build_framework
23-
from dpbench.infrastructure.runner import _print_results
2423
from dpbench.infrastructure.timer import timer
2524

2625
"""
@@ -219,7 +218,7 @@ def runner(c: mpc.Connection) -> None:
219218
framework,
220219
)
221220

222-
_print_results(benchmark_results, framework)
221+
benchmark_results.print(framework.fname, framework.version())
223222

224223
c.send(benchmark_results)
225224

@@ -312,7 +311,7 @@ def run_benchmark_in_sub_process(
312311
results.error_state = ErrorCodes.FAILED_EXECUTION
313312
results.error_msg = "Expected failure"
314313

315-
_print_results(results, None)
314+
results.print()
316315

317316
return results
318317

@@ -323,7 +322,7 @@ def run_benchmark_in_sub_process(
323322
results.error_state = ErrorCodes.UNIMPLEMENTED
324323
results.error_msg = "Unimplemented"
325324

326-
_print_results(results, None)
325+
results.print()
327326

328327
return results
329328

@@ -348,14 +347,14 @@ def run_benchmark_in_sub_process(
348347
results.error_state = ErrorCodes.FAILED_EXECUTION
349348
results.error_msg = "Core dump"
350349

351-
_print_results(results, None)
350+
results.print()
352351
self.kill_process(rc.framework)
353352
else:
354353
results = BenchmarkResults(0, rc.implementation, rc.preset)
355354
results.error_state = ErrorCodes.EXECUTION_TIMEOUT
356355
results.error_msg = "Execution timed out"
357356

358-
_print_results(results, None)
357+
results.print()
359358
self.kill_process(rc.framework)
360359

361360
return results

dpbench/infrastructure/reporter.py

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -326,3 +326,42 @@ def get_unexpected_failures(
326326
)
327327

328328
return failures.difference(expected_failures)
329+
330+
331+
def print_report(
332+
conn: sqlalchemy.Engine,
333+
run_id: int,
334+
implementations: set[str],
335+
comparison_pairs: list[tuple[str, str]] = [],
336+
):
337+
if not implementations:
338+
implementations = {impl.postfix for impl in cfg.GLOBAL.implementations}
339+
340+
implementations = list(implementations)
341+
implementations.sort()
342+
343+
generate_impl_summary_report(
344+
conn, run_id=run_id, implementations=implementations
345+
)
346+
347+
generate_performance_report(
348+
conn,
349+
run_id=run_id,
350+
implementations=implementations,
351+
headless=True,
352+
)
353+
354+
generate_comparison_report(
355+
conn,
356+
run_id=run_id,
357+
implementations=implementations,
358+
comparison_pairs=comparison_pairs,
359+
headless=True,
360+
)
361+
362+
unexpected_failures = get_unexpected_failures(conn, run_id=run_id)
363+
364+
if len(unexpected_failures) > 0:
365+
raise ValueError(
366+
f"Unexpected benchmark implementations failed: {unexpected_failures}.",
367+
)

dpbench/infrastructure/runner.py

Lines changed: 0 additions & 85 deletions
This file was deleted.

0 commit comments

Comments
 (0)