|
14 | 14 | # ============================================================================== |
15 | 15 |
|
16 | 16 |
|
| 17 | +def get_hash(f): |
| 18 | + # content hash for the result file alongside .log file is useful to |
| 19 | + # debug divergent results under what should be identical |
| 20 | + # builds(such as local and CI builds) |
| 21 | + for ext in [".odb", ".rtlil", ".v"]: |
| 22 | + result_file = pathlib.Path( |
| 23 | + str(f).replace("logs/", "results/").replace(".log", ext) |
| 24 | + ) |
| 25 | + if result_file.exists(): |
| 26 | + hasher = hashlib.sha1() |
| 27 | + with open(result_file, "rb") as odb_f: |
| 28 | + while True: |
| 29 | + chunk = odb_f.read(16 * 1024 * 1024) |
| 30 | + if not chunk: |
| 31 | + break |
| 32 | + hasher.update(chunk) |
| 33 | + return hasher.hexdigest() |
| 34 | + return "N/A" |
| 35 | + |
| 36 | + |
17 | 37 | def print_log_dir_times(logdir, args): |
18 | 38 | first = True |
19 | 39 | totalElapsed = 0 |
@@ -67,22 +87,7 @@ def print_log_dir_times(logdir, args): |
67 | 87 | ) |
68 | 88 | break |
69 | 89 |
|
70 | | - # content hash for the result file alongside .log file is useful to |
71 | | - # debug divergent results under what should be identical |
72 | | - # builds(such as local and CI builds) |
73 | | - for ext in [".odb", ".rtlil", ".v"]: |
74 | | - result_file = pathlib.Path( |
75 | | - str(f).replace("logs/", "results/").replace(".log", ext) |
76 | | - ) |
77 | | - if result_file.exists(): |
78 | | - hasher = hashlib.sha1() |
79 | | - with open(result_file, "rb") as odb_f: |
80 | | - while chunk := odb_f.read(16 * 1024 * 1024): |
81 | | - hasher.update(chunk) |
82 | | - odb_hash = hasher.hexdigest() |
83 | | - break |
84 | | - else: |
85 | | - odb_hash = "N/A" |
| 90 | + odb_hash = get_hash(f) |
86 | 91 |
|
87 | 92 | if not found: |
88 | 93 | print("No elapsed time found in", str(f), file=sys.stderr) |
|
0 commit comments