Commit ca5909b9 by Sebastian Renner

Working on parser

parent 519db3c9
...@@ -2,12 +2,12 @@ ...@@ -2,12 +2,12 @@
import os import os
import sys import sys
import re import statistics
def parse_capture(filename): def parse_capture(filename):
f = open('measurements/' + filename) f = open('measurements/' + filename)
#counter = 0 # Skip the first two false positves (risky)
counter = 1 counter = -1
lets_use_a_flag = False lets_use_a_flag = False
six_ts = '' six_ts = ''
two_ts = '' two_ts = ''
...@@ -17,17 +17,18 @@ def parse_capture(filename): ...@@ -17,17 +17,18 @@ def parse_capture(filename):
l_array = l.split(" ") l_array = l.split(" ")
bit_field = l_array[-1][:-1] bit_field = l_array[-1][:-1]
# l_array? That's the best you came up with? # l_array? That's the best you came up with?
if bit_field == '6': if bit_field == '2':
six_ts = l_array[0][:-1] two_ts = l_array[0][:-1]
lets_use_a_flag = True lets_use_a_flag = True
continue continue
if lets_use_a_flag: if lets_use_a_flag:
if bit_field == '2': if bit_field == '6':
#if counter == 0: if counter <= 0:
#counter = counter + 1 counter = counter + 1
#continue lets_use_a_flag = False
two_ts = l_array[0][:-1] continue
delta = float(two_ts) - float(six_ts) six_ts = l_array[0][:-1]
delta = float(six_ts) - float(two_ts)
if counter % 2 == 1: if counter % 2 == 1:
enc_deltas[(counter+1)/2] = delta enc_deltas[(counter+1)/2] = delta
else: else:
...@@ -36,12 +37,23 @@ def parse_capture(filename): ...@@ -36,12 +37,23 @@ def parse_capture(filename):
else: else:
lets_use_a_flag = False lets_use_a_flag = False
f.close() f.close()
for key in enc_deltas:
print("Vector %d was encrypted in %f seconds" % (key, enc_deltas[key])) print("Average enc time[s] = %f" % (statistics.mean(enc_deltas.values())))
for key in dec_deltas: print("Average dec time[s] = %f" % (statistics.mean(dec_deltas.values())))
print("Vector %d was decrypted in %f seconds" % (key, dec_deltas[key])) print()
print(len(enc_deltas)) #for key in enc_deltas:
print(len(dec_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))
def read_log(d): def read_log(d):
# Soo readlines, much efficient # Soo readlines, much efficient
...@@ -60,14 +72,14 @@ def read_log(d): ...@@ -60,14 +72,14 @@ def read_log(d):
f. close() f. close()
print("Let's evaluate the test results of algorithm %s by using %s" % (algorithm, logic_file)) print("Evaluating results for %s" % (algorithm))
parse_capture(logic_file) parse_capture(logic_file)
def main(): def main():
print('THE LWC BENCHMARK SPLITTER') print('THE LWC BENCHMARK SPLITTER')
print('powered by Deutsche Bahn') print('powered by Deutsche Bahn')
build_dir = 'build/' build_dir = 'build/new/'
for d in os.listdir(build_dir): for d in os.listdir(build_dir):
read_log(os.path.join(build_dir + d)) read_log(os.path.join(build_dir + d))
......
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