Parse Go benchmark text output format.
(filepath)
| 122 | |
| 123 | |
| 124 | def parse_benchmark_txt(filepath): |
| 125 | """Parse Go benchmark text output format.""" |
| 126 | results = defaultdict(lambda: defaultdict(dict)) |
| 127 | |
| 128 | with open(filepath, "r") as f: |
| 129 | for line in f: |
| 130 | # Match lines like: BenchmarkFory_NumericStruct_Serialize-10 1234567 789.0 ns/op |
| 131 | match = re.match( |
| 132 | r"Benchmark(\w+)_(\w+)_(Serialize|Deserialize)-\d+\s+\d+\s+([\d.]+)\s+ns/op", |
| 133 | line, |
| 134 | ) |
| 135 | if match: |
| 136 | serializer = match.group(1).lower() |
| 137 | datatype = normalize_datatype(match.group(2).lower()) |
| 138 | operation = match.group(3).lower() |
| 139 | ns_per_op = float(match.group(4)) |
| 140 | |
| 141 | results[datatype][operation][serializer] = ns_per_op |
| 142 | |
| 143 | return results |
| 144 | |
| 145 | |
| 146 | def parse_benchmark_json(filepath): |
no test coverage detected