Commit 5c588c93 by Sebastian Renner

Playing with box plots

parent ca5909b9
......@@ -3,6 +3,7 @@
import os
import sys
import statistics
import matplotlib.pyplot as plt
def parse_capture(filename):
f = open('measurements/' + filename)
......@@ -37,54 +38,71 @@ def parse_capture(filename):
else:
lets_use_a_flag = False
f.close()
print("Average enc time[s] = %f" % (statistics.mean(enc_deltas.values())))
print("Average dec time[s] = %f" % (statistics.mean(dec_deltas.values())))
print()
#for key in enc_deltas:
#print("Vector %d was encrypted in %f seconds" % (key, enc_deltas[key]))
#for key in dec_deltas:
#print("Vector %d was decrypted in %f seconds" % (key, dec_deltas[key]))
enc_len = len(enc_deltas)
dec_len = len(dec_deltas)
if dec_len != enc_len:
raise Exception("#Encryptions (%d) does not match #decryptions (%d)" % (enc_len, dec_len))
if dec_len != 1089 or enc_len != 1089:
raise Exception("#Number of encrypted test vectors (%d)/ decrypted test vectors (%d) does not match guidelines (1089)" % (enc_len, dec_len))
return (enc_deltas, dec_deltas)
def read_log(d):
# Soo readlines, much efficient
f = open(d + '/test_stdout.log', 'r')
content = f.readlines()
are_we_happy = content[-1].split(' ')[-1]
if are_we_happy != 'SUCCESSFUL\n':
print ("Test unsuccesful or log file structure corrupted")
return
# I like to split it, split it
algorithm = content[0].split(' ')[-1].split('/')[-2]
path = content[0].split(' ')[-1].split('/')
if path[-2] == 'ref':
algorithm = path[-3]
else:
algorithm = path[-2]
# Path to logic data is in the second to last line
logic_file = content[-2].split('/')[-1][:-2]
f. close()
print("Evaluating results for %s" % (algorithm))
parse_capture(logic_file)
dicts = parse_capture(logic_file)
return (algorithm, dicts)
def main():
print('THE LWC BENCHMARK SPLITTER')
print('powered by Deutsche Bahn')
build_dir = 'build/new/'
box_plot_data = []
box_plot_labels = []
for d in os.listdir(build_dir):
read_log(os.path.join(build_dir + d))
#dicts[0] --> algo
#dicts[1][0] --> enc
#dicts[1][1] --> dec
dicts = read_log(os.path.join(build_dir + d))
enc_values = dicts[1][0].values()
dec_values = dicts[1][1].values()
box_plot_data.append(list(enc_values))
box_plot_labels.append(dicts[0])
print("Average enc time[s] = %f" % (statistics.mean(enc_values)))
print("Median enc time[s] = %f" % (statistics.median(enc_values)))
print("Average dec time[s] = %f" % (statistics.mean(dec_values)))
print("Median dec time[s] = %f" % (statistics.median(dec_values)))
print()
enc_len = len(dicts[1][0])
dec_len = len(dicts[1][1])
if dec_len != enc_len:
raise Exception("#Encryptions (%d) does not match #decryptions (%d)" % (enc_len, dec_len))
if dec_len != 1089 or enc_len != 1089:
raise Exception("#Number of encrypted test vectors (%d)/ decrypted test vectors (%d) does not match guidelines (1089)" % (enc_len, dec_len))
plt.boxplot(box_plot_data, labels=box_plot_labels)
plt.xticks(rotation=90)
plt.show()
if __name__ == "__main__":
main()
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment