|
4 | 4 | # in the flow and prints it in a table |
5 | 5 | # --------------------------------------------------------------------------- |
6 | 6 |
|
| 7 | +import argparse |
| 8 | +import hashlib |
7 | 9 | import pathlib |
8 | 10 | import os |
9 | | -import argparse # argument parsing |
10 | 11 | import sys |
11 | 12 |
|
12 | 13 | # Parse and validate arguments |
@@ -61,29 +62,48 @@ def print_log_dir_times(logdir, args): |
61 | 62 | int(line.split("Peak memory: ")[1].split("KB")[0]) / 1024 |
62 | 63 | ) |
63 | 64 |
|
| 65 | + # content hash for .odb file alongside .log file is useful to |
| 66 | + # debug divergent results under what should be identical |
| 67 | + # builds(such as local and CI builds) |
| 68 | + odb_file = pathlib.Path( |
| 69 | + str(f).replace("logs/", "results/").replace(".log", ".odb") |
| 70 | + ) |
| 71 | + if odb_file.exists(): |
| 72 | + hasher = hashlib.sha1() |
| 73 | + with open(odb_file, "rb") as odb_f: |
| 74 | + while chunk := odb_f.read(16 * 1024 * 1024): |
| 75 | + hasher.update(chunk) |
| 76 | + odb_hash = hasher.hexdigest() |
| 77 | + else: |
| 78 | + odb_hash = "N/A" |
| 79 | + |
64 | 80 | if not found: |
65 | 81 | print("No elapsed time found in", str(f), file=sys.stderr) |
66 | 82 | continue |
67 | 83 |
|
68 | 84 | # Print the name of the step and the corresponding elapsed time |
69 | | - format_str = "%-25s %20s %14s" |
| 85 | + format_str = "%-25s %10s %14s %20s" |
70 | 86 | if elapsedTime is not None and peak_memory is not None: |
71 | 87 | if first and not args.noHeader: |
72 | | - print(format_str % ("Log", "Elapsed seconds", "Peak Memory/MB")) |
| 88 | + print( |
| 89 | + format_str |
| 90 | + % ("Log", "Elapsed/s", "Peak Memory/MB", "sha1sum .odb [0:20)") |
| 91 | + ) |
73 | 92 | first = False |
74 | 93 | print( |
75 | 94 | format_str |
76 | 95 | % ( |
77 | 96 | os.path.splitext(os.path.basename(str(f)))[0], |
78 | 97 | elapsedTime, |
79 | 98 | peak_memory, |
| 99 | + odb_hash[0:20], |
80 | 100 | ) |
81 | 101 | ) |
82 | 102 | totalElapsed += elapsedTime |
83 | 103 | total_max_memory = max(total_max_memory, int(peak_memory)) |
84 | 104 |
|
85 | 105 | if totalElapsed != 0: |
86 | | - print(format_str % ("Total", totalElapsed, total_max_memory)) |
| 106 | + print(format_str % ("Total", totalElapsed, total_max_memory, "")) |
87 | 107 |
|
88 | 108 |
|
89 | 109 | def scan_logs(args): |
|
0 commit comments