Files
hakmem/benchmarks/scripts/utils/parse_comprehensive_logs.py

55 lines
1.7 KiB
Python
Raw Normal View History

#!/usr/bin/env python3
import sys, os, re
TEST_MAP = {
'Sequential LIFO': 'lifo',
'Sequential FIFO': 'fifo',
'Random Order Free': 'random',
'Interleaved': 'interleave',
'Long-lived vs Short-lived': 'longshort',
'Mixed Sizes': 'mixed',
}
def parse_file(path, allocator):
size = None
cur_test = None
results = []
with open(path,'r',errors='ignore') as f:
for line in f:
m = re.search(r'^SIZE CLASS:\s*(\d+) Bytes', line)
if m:
size = int(m.group(1))
cur_test = None
continue
# Detect tests
for key, short in TEST_MAP.items():
if key != 'Mixed Sizes' and key in line:
cur_test = short
break
if 'Mixed Sizes ---' in line or 'Test 5: Mixed Sizes' in line:
size = 'mixed'
cur_test = 'mixed'
m2 = re.search(r'^Throughput:\s*([0-9.]+) M ops/sec', line)
if m2:
thr = float(m2.group(1))
results.append((allocator, size, cur_test, thr))
return results
def main():
if len(sys.argv) != 2:
print('usage: parse_comprehensive_logs.py <dir>', file=sys.stderr)
sys.exit(1)
d = sys.argv[1]
out = []
for name, alloc in [('hakmem.log','hakmem'),('mimalloc.log','mimalloc'),('system.log','system')]:
p = os.path.join(d,name)
if os.path.exists(p):
out.extend(parse_file(p, alloc))
print('allocator,size,test,throughput_mops')
for rec in out:
print('{},{},{},{}'.format(rec[0], rec[1], rec[2], rec[3]))
if __name__ == '__main__':
main()