Skip to content

Commit

Permalink
cmd/bent: makeover for benchdwarf & benchsize; add assume=exact for u…
Browse files Browse the repository at this point in the history
…nits

Also made these slightly more robust against missing data,
and corrected a bad field reference for args-quality benchmarking.

Change-Id: I5a561d89fac2285e5e23c9e7e730532c3f26a5c6
  • Loading branch information
dr2chase committed Feb 18, 2022
1 parent 1caee45 commit 8688d2e
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 11 deletions.
13 changes: 8 additions & 5 deletions cmd/bent/scripts/benchdwarf
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ 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}'`
# has format nFunctions,argumentError,mixedRegMem,regReuse,tooManyPieces,missingSource,wrongOrder,missingDwarf,duplicated,1-totalErrors/nFunctions
argsquality=`tail -1 $tmp | awk 'BEGIN {FS=","} {print $10}'`
echo "tmp dwarf args quality wc = " `wc -l $tmp`
bench=yes
fi
Expand All @@ -52,13 +52,16 @@ 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
if echo $inputsquality | egrep -q '[.0-9]+' ; then
echo Unit inputs-quality assume=exact
echo "Benchmark${2}_dwarf_input_goodness" 1 ${inputsquality} inputs-quality
fi
if [ "x$y" != "x" ] ; then
if echo $argsquality | egrep -q '[.0-9]+' ; then
echo Unit args-quality assume=exact
echo "Benchmark${2}_dwarf_args_goodness" 1 ${argsquality} args-quality
fi
if [ "x$z" != "x" ] ; then
if echo $stmtquality | egrep -q '[.0-9]+' ; then
echo Unit stmts-quality assume=exact
echo "Benchmark${2}_dwarf_stmt_goodness" 1 ${stmtquality} stmts-quality
# echo "Benchmark${2}_dwarf_stmt_goodness_kind" 1 ${stmtkindquality} stmts-quality
fi
Expand Down
40 changes: 34 additions & 6 deletions cmd/bent/scripts/benchsize
Original file line number Diff line number Diff line change
Expand Up @@ -33,22 +33,50 @@ zdebug_abbrev=`grep zdebug_abbrev $tmp | awk -Wposix "$awkcommand"`
zdebug_pubname=`grep zdebug_pubname $tmp | awk -Wposix "$awkcommand"`
zdebug_pubtype=`grep zdebug_pubtype $tmp | awk -Wposix "$awkcommand"`

zdebug_info=${zdebug_info:-0}
zdebug_loc=${zdebug_loc:-0}
zdebug_line=${zdebug_line:-0}
zdebug_ranges=${zdebug_ranges:-0}
zdebug_frame=${zdebug_frame:-0}
zdebug_abbrev=${zdebug_abbrev:-0}
zdebug_pubname=${zdebug_pubname:-0}
zdebug_pubtype=${zdebug_pubtype:-0}

echo "goos: $GOOS"
echo "goarch: $GOARCH"
echo "pkg:" # Erase any inherited pkg if files are concatenated
echo "Benchmark${2}_total" 1 ${total} total-bytes
echo "Benchmark${2}_text" 1 ${text} text-bytes
echo "Benchmark${2}_data" 1 ${data} data-bytes
echo "Benchmark${2}_rodata" 1 ${rodata} rodata-bytes
echo "Benchmark${2}_pclntab" 1 ${gopclntab} pclntab-bytes

if echo $total | egrep -q '[0-9]+' ; then
echo Unit total-bytes assume=exact
echo "Benchmark${2}_total" 1 ${total} total-bytes
fi

if echo $text | egrep -q '[0-9]+' ; then
echo Unit text-bytes assume=exact
echo "Benchmark${2}_text" 1 ${text} text-bytes
fi

if echo $data | egrep -q '[0-9]+' ; then
echo Unit data-bytes assume=exact
echo "Benchmark${2}_data" 1 ${data} data-bytes
fi

if echo $rodata | egrep -q '[0-9]+' ; then
echo Unit rodata-bytes assume=exact
echo "Benchmark${2}_rodata" 1 ${rodata} rodata-bytes
fi

if echo $gopclntab | egrep -q '[0-9]+' ; then
echo Unit pclntab-bytes assume=exact
echo "Benchmark${2}_pclntab" 1 ${gopclntab} pclntab-bytes
fi

zdebug=`expr ${zdebug_info} + ${zdebug_loc} + ${zdebug_line} + ${zdebug_ranges} + ${zdebug_frame} + ${zdebug_abbrev} + ${zdebug_pubname} + ${zdebug_pubtype}`

echo "Benchmark${2}_zdebug_total" 1 ${zdebug} zdebug-bytes
if echo $zdebug | egrep -q '[0-9]+' ; then
echo Unit zdebug-bytes assume=exact
echo "Benchmark${2}_zdebug_total" 1 ${zdebug} zdebug-bytes
fi

# echo "Benchmark${2}_zdebug_info" 1 ${zdebug_info} zdebugbytes
# echo "Benchmark${2}_zdebug_loc" 1 ${zdebug_loc} zdebugbytes
Expand Down

0 comments on commit 8688d2e

Please sign in to comment.