-rwxr-xr-x 2180 libmceliece-20240812/autogen/md-speed raw
#!/usr/bin/env python3 import os uarchdate = { 'a53':20121030, 'a72':20160101, # XXX: announced in 2015.02 but supposedly not shipped until 2016 'airmont':20150401, # XXX: not sure about exact date 'broadwell':20141027, 'core2':20060726, 'firestorm':20201110, 'goldencove':20211104, 'goldmont':20160418, 'haswell':20130604, 'skylake':20150805, 'tigerlake':20200902, 'zen2':20190707, 'zen3':20201105, } uarchname = { 'a53':'Cortex-A53 (2012)', 'a72':'Cortex-A72 (2016)', 'airmont':'Airmont (2015)', 'broadwell':'Broadwell (2014)', 'core2':'Core 2 (2006)', 'firestorm':'Firestorm (2020)', 'goldencove':'Golden Cove (2021)', 'goldmont':'Goldmont (2016)', 'haswell':'Haswell (2013)', 'skylake':'Skylake (2015)', 'tigerlake':'Tiger Lake (2020)', 'zen2':'Zen 2 (2019)', 'zen3':'Zen 3 (2020)', } sizes = '348864','460896','6688128','6960119','8192128' def sortkey(m): uarch = ''.join(m.split('-')[:1]) return uarchdate[uarch] machines = sorted(os.listdir('benchmarks'),key=sortkey,reverse=True) def mceliece(m): uarch = uarchname[''.join(m.split('-')[:1])] benchmarksdir = 'benchmarks' keypair = {} enc = {} dec = {} with open(f'{benchmarksdir}/{m}') as f: for line in f: line = line.split() if len(line) < 4: continue for size in sizes: for kem in f'{size}f',f'{size}': if line[:2] == [f'kem_{kem}_keypair','selected']: keypair[kem] = int(line[3]) if line[:2] == [f'kem_{kem}_enc','selected']: enc[kem] = int(line[3]) if line[:2] == [f'kem_{kem}_dec','selected']: dec[kem] = int(line[3]) C = '' D = '' for size in sizes: for kem in f'{size}f',f'{size}': out.write(f'| {uarch} | {kem} | {C}{keypair[kem]}{D} | {C}{enc[kem]}{D} | {C}{dec[kem]}{D}\n') uarch = '' with open('doc/speed.md','w') as out: with open('autogen/md-speed-top') as f: out.write(f.read()) out.write('\n\n') out.write('| μarch | KEM | keypair | enc | dec |\n') out.write('| :---- | :--- | ------: | ---: | ---: |\n') for m in machines: mceliece(m) out.write('\n\n') with open('autogen/md-speed-bot') as f: out.write(f.read())