| #!/bin/bash |
| |
| tmp=tmp-bench-size-$$ |
| |
| if [ `uname` = "Darwin" ] ; then |
| awkcommand='{print $3}' |
| size -m "$1" > $tmp |
| else |
| x=`which gsize` |
| awkcommand='{print $2}' |
| if [ "x$x" = "x" ] ; then |
| size -A "$1" > $tmp |
| else |
| "$x" -A "$1" > $tmp |
| fi |
| fi |
| |
| |
| # note total is different -- always $2 |
| total=`egrep -i '^total' $tmp | awk -Wposix '{print $2}'` |
| |
| text=`egrep [^a-z]text[^a-z] $tmp | awk -Wposix "$awkcommand"` |
| gopclntab=`grep gopclntab $tmp | awk -Wposix "$awkcommand"` |
| rodata=`grep rodata $tmp | awk -Wposix "$awkcommand"` |
| data=`egrep [^a-z]data[^a-z._] $tmp | awk -Wposix "$awkcommand"` |
| |
| zdebug_info=`grep zdebug_info $tmp | awk -Wposix "$awkcommand"` |
| zdebug_loc=`grep zdebug_loc $tmp | awk -Wposix "$awkcommand"` |
| zdebug_line=`grep zdebug_line $tmp | awk -Wposix "$awkcommand"` |
| zdebug_ranges=`grep zdebug_ranges $tmp | awk -Wposix "$awkcommand"` |
| zdebug_frame=`grep zdebug_frame $tmp | awk -Wposix "$awkcommand"` |
| 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_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 |
| |
| 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 |
| |
| # echo "Benchmark${2}_zdebug_info" 1 ${zdebug_info} zdebugbytes |
| # echo "Benchmark${2}_zdebug_loc" 1 ${zdebug_loc} zdebugbytes |
| # echo "Benchmark${2}_zdebug_line" 1 ${zdebug_line} zdebugbytes |
| # echo "Benchmark${2}_zdebug_ranges" 1 ${zdebug_ranges} zdebugbytes |
| # echo "Benchmark${2}_zdebug_frame" 1 ${zdebug_frame} zdebugbytes |
| # echo "Benchmark${2}_zdebug_pubtype" 1 ${zdebug_pubtype} zdebugbytes |
| # echo "Benchmark${2}_zdebug_pubname" 1 ${zdebug_pubname} zdebugbytes |
| |
| rm $tmp |