(opts)
| 399 | |
| 400 | |
| 401 | def main(opts): |
| 402 | global WORK_SCALE |
| 403 | if not hasattr(sys, "_is_gil_enabled") or sys._is_gil_enabled(): |
| 404 | sys.stderr.write("expected to be run with the GIL disabled\n") |
| 405 | |
| 406 | benchmark_names = opts.benchmarks |
| 407 | if benchmark_names: |
| 408 | for name in benchmark_names: |
| 409 | if name not in ALL_BENCHMARKS: |
| 410 | sys.stderr.write(f"Unknown benchmark: {name}\n") |
| 411 | sys.exit(1) |
| 412 | else: |
| 413 | benchmark_names = ALL_BENCHMARKS.keys() |
| 414 | |
| 415 | WORK_SCALE = opts.scale |
| 416 | |
| 417 | if not opts.baseline_only: |
| 418 | initialize_threads(opts) |
| 419 | |
| 420 | do_bench = not opts.baseline_only and not opts.parallel_only |
| 421 | for name in benchmark_names: |
| 422 | func = ALL_BENCHMARKS[name] |
| 423 | if do_bench: |
| 424 | benchmark(func) |
| 425 | continue |
| 426 | |
| 427 | if opts.parallel_only: |
| 428 | delta_ns = bench_parallel(func) |
| 429 | else: |
| 430 | delta_ns = bench_one_thread(func) |
| 431 | |
| 432 | time_ms = delta_ns / 1_000_000 |
| 433 | print(f"{func.__name__:<18} {time_ms:.1f} ms") |
| 434 | |
| 435 | |
| 436 | if __name__ == "__main__": |
no test coverage detected
searching dependent graphs…