forked from mupq/pqm4
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbenchmarks_to_md.py
executable file
·64 lines (52 loc) · 2.87 KB
/
benchmarks_to_md.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
#!/usr/bin/env python3
import os
import numpy as np
BENCHMARK_DIR = 'benchmarks/'
def parseData(fileContents):
parts = fileContents.split("\n")
keygen = int(parts[1])
encsign = int(parts[3])
decverify = int(parts[5])
return [keygen, encsign, decverify]
def getStats(l):
return "AVG: {:,} <br /> MIN: {:,} <br /> MAX: {:,}".format(int(np.mean(l)), min(l), max(l));
def formatData(scheme, implementation, data, printStats):
if printStats:
keygen = getStats([item[0] for item in data])
encsign = getStats([item[1] for item in data])
decverify = getStats([item[2] for item in data])
print("| {} ({} executions) | {} | {} | {} | {} |".format(scheme,len(data), implementation, keygen, encsign, decverify))
else:
keygen = "{:,}".format(max([item[0] for item in data]))
encsign = "{:,}".format(max([item[1] for item in data]))
decverify = "{:,}".format( max([item[2] for item in data]))
print("| {} | {} | {} | {} | {} |".format(scheme, implementation, keygen, encsign, decverify))
def processPrimitives(path, printStats):
if os.path.exists(path) == False:
return;
for scheme in sorted(os.listdir(path)):
for implementation in sorted(os.listdir(path+"/"+scheme)):
measurements = []
for measurement in os.listdir(path+"/"+scheme+"/"+implementation):
with open(path+"/"+scheme+"/"+implementation+"/"+measurement, "r") as f:
d = parseData(f.read())
measurements.append(d)
formatData(scheme, implementation, measurements, printStats)
print("### Speed Evaluation")
print("#### Key Encapsulation Schemes")
print("| scheme | implementation | key generation [cycles] | encapsulation [cycles] | decapsulation [cycles] |")
print("| ------ | -------------- | ----------------------- | ---------------------- | -----------------------|")
processPrimitives(BENCHMARK_DIR+"speed/crypto_kem/", True)
print("#### Signature Schemes")
print("| scheme | implementation | key generation [cycles] | sign [cycles] | verify [cycles] |")
print("| ------ | -------------- | ----------------------- | ------------- | ----------------|")
processPrimitives(BENCHMARK_DIR+"speed/crypto_sign/", True)
print("### Memory Evaluation")
print("#### Key Encapsulation Schemes")
print("| scheme | implementation | key generation [bytes] | encapsulation [bytes] | decapsulation [bytes] |")
print("| ------ | -------------- | ----------------------- | ---------------------- | -----------------------|")
processPrimitives(BENCHMARK_DIR+"stack/crypto_kem/", False)
print("#### Signature Schemes")
print("| scheme | implementation | key generation [bytes] | sign [bytes] | verify [bytes] |")
print("| ------ | -------------- | ----------------------- | ------------- | ----------------|")
processPrimitives(BENCHMARK_DIR+"stack/crypto_sign/", False)