From 734c20f22bbc9e7b0575997a4dfbfcc5a4afa0da Mon Sep 17 00:00:00 2001 From: "waterson%netscape.com" Date: Sun, 21 Oct 2001 16:46:37 +0000 Subject: [PATCH] Add coverage and floating width. git-svn-id: svn://10.0.0.236/trunk@105902 18797224-902f-48f8-a5cc-f745e15eee43 --- mozilla/tools/trace-malloc/histogram-pretty.sh | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/mozilla/tools/trace-malloc/histogram-pretty.sh b/mozilla/tools/trace-malloc/histogram-pretty.sh index 2b44f9348ac..765aa00f2b5 100755 --- a/mozilla/tools/trace-malloc/histogram-pretty.sh +++ b/mozilla/tools/trace-malloc/histogram-pretty.sh @@ -27,13 +27,14 @@ # # Usage: # -# histogram-pretty.sh [-c ] +# histogram-pretty.sh [-c ] [-w ] # # Pretty-print the histogram in file , displaying at most # rows. # How many rows are we gonna show? COUNT=20 +WIDTH=22 # Read arguments while [ $# -gt 0 ]; do @@ -41,6 +42,9 @@ while [ $# -gt 0 ]; do -c) COUNT=$2 shift 2 ;; + -w) WIDTH=$2 + shift 2 + ;; *) break ;; esac @@ -57,19 +61,22 @@ sort -nr +2 ${FILE} >> /tmp/$$.sorted # Pretty-print, including percentages cat < /tmp/$$.awk BEGIN { - print "Type Count Bytes %Total"; + printf "%-${WIDTH}s Count Bytes %Total %Cov\n", "Type"; } \$1 == "TOTAL" { tbytes = \$3; } NR <= $COUNT { - printf "%-22s %6d %8d %6.2lf\n", \$1, \$2, \$3, 100.0 * \$3 / tbytes; + if (\$1 != "TOTAL") { + covered += \$3; + } + printf "%-${WIDTH}s %6d %8d %6.2lf %6.2lf\n", \$1, \$2, \$3, 100.0 * \$3 / tbytes, 100.0 * covered / tbytes; } NR > $COUNT { - oobjs += \$2; obytes += \$3; + oobjs += \$2; obytes += \$3; covered += \$3; } END { - printf "%-22s %6d %8d %6.2lf\n", "OTHER", oobjs, obytes, obytes * 100.0 / tbytes; + printf "%-${WIDTH}s %6d %8d %6.2lf %6.2lf\n", "OTHER", oobjs, obytes, obytes * 100.0 / tbytes, covered * 100.0 / tbytes; } EOF