|
| 1 | +#!/usr/bin/env python3 |
1 | 2 | import sys |
2 | 3 |
|
3 | 4 | from pathlib import Path |
4 | 5 |
|
| 6 | +from util import capitalize_implementation, info_from_path, print_sep |
| 7 | + |
5 | 8 | try: |
6 | | - other = sys.argv[1] |
| 9 | + arg = sys.argv[1] |
7 | 10 | except IndexError: |
8 | | - other = "PyPy" |
| 11 | + arg = "pypy" |
| 12 | + |
| 13 | +path_result_cpy = Path("tmp_results_cpy.txt") |
| 14 | + |
| 15 | +path_result_other = Path(arg) |
9 | 16 |
|
10 | | -path_result_cpy = Path("tmp_results_cpython.txt") |
11 | | -path_result_other = Path(f"tmp_results_{other.lower()}.txt") |
| 17 | +if not path_result_other.exists(): |
| 18 | + path_result_other = Path(f"tmp_results_{arg}.txt") |
12 | 19 |
|
13 | 20 | assert path_result_cpy.exists() |
14 | 21 | assert path_result_other.exists() |
@@ -47,17 +54,24 @@ def data_from_path(path): |
47 | 54 | return names, times_cpy, times_hpy |
48 | 55 |
|
49 | 56 |
|
50 | | -names, times_cpy_cpy, times_cpy_hpy = data_from_path(path_result_cpy) |
| 57 | +info = info_from_path(path_result_other) |
| 58 | + |
| 59 | +implementation = info["implementation"] |
| 60 | + |
| 61 | +names_cpy, times_cpy_cpy, times_cpy_hpy = data_from_path(path_result_cpy) |
51 | 62 | names, times_other_cpyext, times_other_hpy = data_from_path(path_result_other) |
52 | 63 |
|
| 64 | +assert names_cpy == names |
| 65 | + |
53 | 66 | max_length_name = 45 |
54 | 67 | fmt_name = f"{{:{max_length_name}s}}" |
55 | 68 |
|
56 | | -out = f" {other} / CPy native (time ratio, smaller is better) " |
57 | | -num_chars = 81 |
58 | | -num_equals = (num_chars - len(out)) // 2 |
| 69 | +print_sep( |
| 70 | + f"{capitalize_implementation(implementation)} / CPy native (time ratio, smaller is better)" |
| 71 | +) |
59 | 72 |
|
60 | | -print(num_equals * "=" + out + num_equals * "=") |
| 73 | +if info["short prefix"] != implementation: |
| 74 | + print(f"short prefix: {info['short prefix']}") |
61 | 75 |
|
62 | 76 | if times_other_cpyext: |
63 | 77 | print(max_length_name * " " + "cpyext HPy univ") |
|
0 commit comments