| #!/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 |