summaryrefslogtreecommitdiff
path: root/misc/benchcmp
diff options
context:
space:
mode:
authorShenghou Ma <minux.ma@gmail.com>2012-12-22 14:51:16 -0500
committerShenghou Ma <minux.ma@gmail.com>2012-12-22 14:51:16 -0500
commitc685dabc3926dcfc5ffe225057b2f770d19ed943 (patch)
tree50c46a9e3a0179390017c16f57736850dd89f498 /misc/benchcmp
parent140e2e3e9cbe770ee7a106fa75087465a78e7995 (diff)
downloadgo-c685dabc3926dcfc5ffe225057b2f770d19ed943.tar.gz
misc/benchcmp: show byte allocation statistics
R=golang-dev, rsc CC=golang-dev https://codereview.appspot.com/6971048 Committer: Russ Cox <rsc@golang.org>
Diffstat (limited to 'misc/benchcmp')
-rwxr-xr-xmisc/benchcmp34
1 files changed, 30 insertions, 4 deletions
diff --git a/misc/benchcmp b/misc/benchcmp
index b98ee2b2f..3180f57ea 100755
--- a/misc/benchcmp
+++ b/misc/benchcmp
@@ -35,18 +35,28 @@ $1 ~ /Benchmark/ && $4 == "ns/op" {
# allocs/op might be at $8 or $10 depending on if
# SetBytes was used or not.
- if($8 == "allocs/op")
+ # B/op might be at $6 or $8, it should be immediately
+ # followed by allocs/op
+ if($8 == "allocs/op") {
+ newbytes[$1] = $5
newalloc[$1] = $7
- if($10 == "allocs/op")
+ }
+ if($10 == "allocs/op") {
+ newbytes[$1] = $7
newalloc[$1] = $9
+ }
} else {
old[$1] = $3
if($6 == "MB/s")
oldmb[$1] = $5
- if($8 == "allocs/op")
+ if($8 == "allocs/op") {
+ oldbytes[$1] = $5
oldalloc[$1] = $7
- if($10 == "allocs/op")
+ }
+ if($10 == "allocs/op") {
+ oldbytes[$1] = $7
oldalloc[$1] = $9
+ }
}
}
@@ -94,5 +104,21 @@ END {
printf("%-*s %12d %12d %6s%%\n", len, what,
oldalloc[what], newalloc[what], delta)
}
+
+ # print alloc bytes
+ anybytes = 0
+ for(i=0; i<n; i++) {
+ what = name[i]
+ if(!(what in newbytes))
+ continue
+ if(anybytes++ == 0)
+ printf("\n%-*s %12s %12s %7s\n", len, "benchmark", "old bytes", "new bytes", "delta")
+ if(oldbytes[what] == 0)
+ delta="n/a"
+ else
+ delta=sprintf("%.2f", 100*newbytes[what]/oldbytes[what]-100)
+ printf("%-*s %12d %12d %6s%%\n", len, what,
+ oldbytes[what], newbytes[what], delta)
+ }
}
' "$@"