From 8688d2e97b3f0cee41ab4a7f4bbe827d2c88868d Mon Sep 17 00:00:00 2001 From: David Chase Date: Fri, 18 Feb 2022 15:00:01 -0500 Subject: [PATCH] cmd/bent: makeover for benchdwarf & benchsize; add assume=exact for units Also made these slightly more robust against missing data, and corrected a bad field reference for args-quality benchmarking. Change-Id: I5a561d89fac2285e5e23c9e7e730532c3f26a5c6 --- cmd/bent/scripts/benchdwarf | 13 +++++++----- cmd/bent/scripts/benchsize | 40 +++++++++++++++++++++++++++++++------ 2 files changed, 42 insertions(+), 11 deletions(-) diff --git a/cmd/bent/scripts/benchdwarf b/cmd/bent/scripts/benchdwarf index 3545f1d..dbe15a1 100755 --- a/cmd/bent/scripts/benchdwarf +++ b/cmd/bent/scripts/benchdwarf @@ -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 @@ -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 diff --git a/cmd/bent/scripts/benchsize b/cmd/bent/scripts/benchsize index 4b48be1..d987b12 100755 --- a/cmd/bent/scripts/benchsize +++ b/cmd/bent/scripts/benchsize @@ -33,6 +33,11 @@ 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} @@ -40,15 +45,38 @@ 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