Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
lwc
/
compare
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Pipelines
Members
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
dae7a416
authored
Jul 18, 2019
by
Enrico Pozzobon
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'master' of lab.las3.de:lwc/compare
parents
64dd645a
5c588c93
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
57 additions
and
27 deletions
+57
-27
parse_logic.py
+57
-27
No files found.
parse_logic.py
View file @
dae7a416
...
...
@@ -2,12 +2,13 @@
import
os
import
sys
import
re
import
statistics
import
matplotlib.pyplot
as
plt
def
parse_capture
(
filename
):
f
=
open
(
'measurements/'
+
filename
)
#
counter = 0
counter
=
1
#
Skip the first two false positves (risky)
counter
=
-
1
lets_use_a_flag
=
False
six_ts
=
''
two_ts
=
''
...
...
@@ -17,17 +18,18 @@ def parse_capture(filename):
l_array
=
l
.
split
(
" "
)
bit_field
=
l_array
[
-
1
][:
-
1
]
# l_array? That's the best you came up with?
if
bit_field
==
'
6
'
:
six
_ts
=
l_array
[
0
][:
-
1
]
if
bit_field
==
'
2
'
:
two
_ts
=
l_array
[
0
][:
-
1
]
lets_use_a_flag
=
True
continue
if
lets_use_a_flag
:
if
bit_field
==
'2'
:
#if counter == 0:
#counter = counter + 1
#continue
two_ts
=
l_array
[
0
][:
-
1
]
delta
=
float
(
two_ts
)
-
float
(
six_ts
)
if
bit_field
==
'6'
:
if
counter
<=
0
:
counter
=
counter
+
1
lets_use_a_flag
=
False
continue
six_ts
=
l_array
[
0
][:
-
1
]
delta
=
float
(
six_ts
)
-
float
(
two_ts
)
if
counter
%
2
==
1
:
enc_deltas
[(
counter
+
1
)
/
2
]
=
delta
else
:
...
...
@@ -36,43 +38,71 @@ def parse_capture(filename):
else
:
lets_use_a_flag
=
False
f
.
close
()
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
]))
print
(
len
(
enc_deltas
))
print
(
len
(
dec_deltas
))
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
(
"Let's evaluate the test results of algorithm
%
s by using
%
s"
%
(
algorithm
,
logic_file
))
parse_capture
(
logic_file
)
print
(
"Evaluating results for
%
s"
%
(
algorithm
))
dicts
=
parse_capture
(
logic_file
)
return
(
algorithm
,
dicts
)
def
main
():
print
(
'THE LWC BENCHMARK SPLITTER'
)
print
(
'powered by Deutsche Bahn'
)
build_dir
=
'build/'
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
()
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment