Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Andrea Gussoni
artifacts-asiaccs20
Commits
54ca0d01
Commit
54ca0d01
authored
Dec 16, 2020
by
Andrea Gussoni
Browse files
Add script to compute the average dimension match
parent
9c4af8fd
Changes
2
Hide whitespace changes
Inline
Side-by-side
scripting/boundaries-comparison-scripts/boundaries-percentage.py
0 → 100755
View file @
54ca0d01
#!/usr/bin/env python3
import
argparse
import
csv
import
json
import
math
import
matplotlib.mlab
as
mlab
import
matplotlib.pyplot
as
plt
import
matplotlib.patches
as
mpatches
import
numpy
as
np
import
os
import
seaborn
def
get_change
(
current
,
previous
):
if
current
==
previous
:
return
0.0
try
:
return
((
current
-
previous
)
/
previous
)
*
100.0
except
ZeroDivisionError
:
return
100.0
# Function that takes as parameter a platform and computes averages and variance of the results, and saves them in two dedicated files (averages.dat and variances.dat)
def
compute_matches
(
binaries_list
,
arch
,
output_name
):
average_list
=
[]
average_dimension_list
=
[]
for
binary
in
binaries_list
:
inputfile
=
'result-'
+
arch
+
"/"
+
binary
print
(
"Analyzing: "
+
inputfile
)
with
open
(
inputfile
,
'r'
)
as
input
:
data_dict
=
json
.
load
(
input
)
tot_counter
=
0
pos_counter
=
0
tot_dimension
=
0
matching_dimension
=
0
for
elem
in
data_dict
:
tot_counter
+=
1
match
=
elem
[
'match'
]
symbol_dimension
=
elem
[
'symbol_coverage_measure'
]
tot_dimension
+=
symbol_dimension
if
match
==
'True'
:
pos_counter
+=
1
matching_dimension
+=
symbol_dimension
average_list
.
append
(
pos_counter
/
tot_counter
)
average_dimension_list
.
append
(
matching_dimension
/
tot_dimension
)
print
(
"For binary "
+
binary
+
" the average matching is: "
+
str
(
pos_counter
/
tot_counter
))
print
(
"For binary "
+
binary
+
" the matching dimension is: "
+
str
(
matching_dimension
/
tot_dimension
))
print
(
"Overall recap"
)
print
(
"Average matching is: "
+
str
(
sum
(
average_list
)
/
len
(
average_list
)))
print
(
"Average matching dimension is: "
+
str
(
sum
(
average_dimension_list
)
/
len
(
average_dimension_list
)))
def
main
():
parser
=
argparse
.
ArgumentParser
(
description
=
'My nice tool.'
)
parser
.
add_argument
(
'binaries'
,
metavar
=
'BINARIESFILE'
,
help
=
'File containing the names of the binaries'
)
parser
.
add_argument
(
'arch'
,
metavar
=
'ARCH'
,
help
=
'Architecture'
)
parser
.
add_argument
(
'output_name'
,
metavar
=
'OUTPUT_NAME'
,
help
=
'Output Name'
)
args
=
parser
.
parse_args
()
arch
=
args
.
arch
binaries
=
args
.
binaries
output_name
=
args
.
output_name
with
open
(
binaries
,
'r'
)
as
binaries_file
:
binaries_list
=
[
line
.
rstrip
(
'
\n
'
)
for
line
in
binaries_file
]
# Call the funciton that computes the results
compute_matches
(
binaries_list
,
arch
,
output_name
)
if
__name__
==
"__main__"
:
main
()
scripting/boundaries-comparison-scripts/boundaries-percentage.sh
0 → 100755
View file @
54ca0d01
#!/bin/bash
if
[
$#
-eq
0
]
;
then
echo
"No arguments supplied"
exit
1
fi
arch
=
$1
# Import the config
.
./config.sh
$matching_script_dir
/boundaries-percentage.py
$binaries_file
$arch
$matching_dir
output
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new 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