-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathbenchdwarf
executable file
·67 lines (58 loc) · 2.1 KB
/
benchdwarf
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
65
66
67
#!/bin/bash
x=`which dwarf-goodness`
y=`which optargorder`
z=`which nostmt`
tmp=tmp-bench-dwarf-$$
bench=no
# make it exist so it can be removed
cat /dev/null > $tmp
# Measures fraction of input variables to lines that are present
if [ "x$x" = "x" ] ; then
echo "Can get dwarf-goodness command with 'go get github.com/dr2chase/dwarf-goodness/cmd/dwarf-goodness'"
else
dwarf-goodness "$1" > $tmp
# has format #inputs, #present, ratio, difference
inputsquality=`tail -1 $tmp | awk 'BEGIN {FS=","} {print $3}'`
echo "tmp dwarf line quality wc = " `wc -l $tmp`
bench=yes
fi
# Measures fraction of function arguments that are present at function entry
if [ "x$y" = "x" ] ; then
echo "Can get optargorder command with 'go get github.com/dr2chase/optargorder'"
else
optargorder "$1" > $tmp
# has format nFunctions,argumentError,tooManyPieces,missingSource,wrongOrder,missingDwarf,1-totalErrors/nFunctions
argsquality=`tail -1 $tmp | awk 'BEGIN {FS=","} {print $7}'`
echo "tmp dwarf args quality wc = " `wc -l $tmp`
bench=yes
fi
# Measures fraction of lines mentioned in dwarf that are tagged as "is_stmt"
if [ "x$z" = "x" ] ; then
echo "Can get nostmt command with 'go get github.com/dr2chase/nostmt'"
else
nostmt -c "$1" > $tmp
# has total,nostmt,1-nostmt/total
stmtquality=`tail -1 $tmp | awk 'BEGIN {FS=","} {print $3}'`
echo "tmp stmt args quality wc = " `wc -l $tmp`
nostmt -c -k "$1" > $tmp
# has total,nostmt,1-nostmt/total
stmtkindquality=`tail -1 $tmp | awk 'BEGIN {FS=","} {print $3}'`
echo "tmp stmt args kind quality wc = " `wc -l $tmp`
bench=yes
fi
if [ ${bench} = "yes" ] ; then
echo "goos: $GOOS"
echo "goarch: $GOARCH"
echo "pkg:" # Erase any inherited pkg if files are concatenated
if [ "x$x" != "x" ] ; then
echo "Benchmark${2}_dwarf_input_goodness" 1 ${inputsquality} inputs-quality
fi
if [ "x$y" != "x" ] ; then
echo "Benchmark${2}_dwarf_args_goodness" 1 ${argsquality} args-quality
fi
if [ "x$z" != "x" ] ; then
echo "Benchmark${2}_dwarf_stmt_goodness" 1 ${stmtquality} stmts-quality
# echo "Benchmark${2}_dwarf_stmt_goodness_kind" 1 ${stmtkindquality} stmts-quality
fi
fi
rm $tmp