MCPcopy Create free account
hub / github.com/apache/fory / parse_benchmark_txt

Function parse_benchmark_txt

benchmarks/go/benchmark_report.py:124–143  ·  view source on GitHub ↗

Parse Go benchmark text output format.

(filepath)

Source from the content-addressed store, hash-verified

122
123
124def 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
146def parse_benchmark_json(filepath):

Callers 1

mainFunction · 0.85

Calls 2

normalize_datatypeFunction · 0.70
matchMethod · 0.45

Tested by

no test coverage detected