|
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
|
@@ -66,22 +86,7 @@ def print_log_dir_times(logdir, args):
|
66 | 86 | int(line.split("Peak memory: ")[1].split("KB")[0]) / 1024
|
67 | 87 | )
|
68 | 88 |
|
69 |
| - # content hash for the result file alongside .log file is useful to |
70 |
| - # debug divergent results under what should be identical |
71 |
| - # builds(such as local and CI builds) |
72 |
| - for ext in [".odb", ".rtlil", ".v"]: |
73 |
| - result_file = pathlib.Path( |
74 |
| - str(f).replace("logs/", "results/").replace(".log", ext) |
75 |
| - ) |
76 |
| - if result_file.exists(): |
77 |
| - hasher = hashlib.sha1() |
78 |
| - with open(result_file, "rb") as odb_f: |
79 |
| - while chunk := odb_f.read(16 * 1024 * 1024): |
80 |
| - hasher.update(chunk) |
81 |
| - odb_hash = hasher.hexdigest() |
82 |
| - break |
83 |
| - else: |
84 |
| - odb_hash = "N/A" |
| 89 | + odb_hash = get_hash(f) |
85 | 90 |
|
86 | 91 | if not found:
|
87 | 92 | print("No elapsed time found in", str(f), file=sys.stderr)
|
|
0 commit comments