forked from alecthomas/go_serialization_benchmarks
-
Notifications
You must be signed in to change notification settings - Fork 0
/
stats
executable file
·26 lines (25 loc) · 827 Bytes
/
stats
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
#!/bin/bash
go test -bench=".*" ./ 2>/dev/null|
awk -F' ' '
BEGIN {
print "benchmark iter time/iter bytes/op allocs/op tt.time tt.bytes time/alloc"
}
/Benchmark/ {
gsub(/ +/," ",$0)
printf "%-40s %10d %6d %s %5d %s %3d %s %6.2f s %7d KB %7.2f ns/alloc\n",$1,$2,$3,$4,$5,$6,$7,$8,$2*$3/1000000000,$2*$5/10000,$3/$7
gsub(/(Unm|M)arshal/,"",$1)
pname[$1]=$1
for (i=2; i<NF; i++) {
if ($i ~ /[0-9]/) proto[$1,i]+=$i
else proto[$1,i]=$i
}
}
END {
print "---\ntotals:"
for (p in pname) {
pr=pname[p]
printf "%-40s %10d %6d %s %5d %s %3d %s %6.2f s %7d KB %7.2f ns/alloc\n",pr,proto[pr,2],proto[pr,3],proto[pr,4],proto[pr,5],proto[pr,6],proto[pr,7],
proto[pr,8],proto[pr,2]*proto[pr,3]/1000000000,proto[pr,2]*proto[pr,5]/10000,proto[pr,3]/proto[pr,7]
}
}
'