OLD | NEW |
1 #!/bin/sh | 1 #!/bin/sh |
2 # Copyright 2011 The Go Authors. All rights reserved. | 2 # Copyright 2011 The Go Authors. All rights reserved. |
3 # Use of this source code is governed by a BSD-style | 3 # Use of this source code is governed by a BSD-style |
4 # license that can be found in the LICENSE file. | 4 # license that can be found in the LICENSE file. |
5 | 5 |
6 case "$1" in | 6 case "$1" in |
7 -*)····· | 7 -*)····· |
8 echo 'usage: benchcmp old.txt new.txt' >&2 | 8 echo 'usage: benchcmp old.txt new.txt' >&2 |
9 echo >&2 | 9 echo >&2 |
10 » echo 'Each input file should be gotest -bench output.' >&2 | 10 » echo 'Each input file should be go test -test.run=NONE -test.bench=. > [
old,new].txt' >&2 |
11 echo 'Benchcmp compares the first and last for each benchmark.' >&2 | 11 echo 'Benchcmp compares the first and last for each benchmark.' >&2 |
12 exit 2 | 12 exit 2 |
13 esac | 13 esac |
14 | 14 |
15 awk ' | 15 awk ' |
16 BEGIN { | 16 BEGIN { |
17 n = 0 | 17 n = 0 |
18 } | 18 } |
19 | 19 |
20 $1 ~ /Benchmark/ && $4 == "ns/op" { | 20 $1 ~ /Benchmark/ && $4 == "ns/op" { |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
57 continue | 57 continue |
58 if(anymb++ == 0) | 58 if(anymb++ == 0) |
59 printf("\n%-*s %12s %12s %7s\n", len, "benchmark", "old
MB/s", "new MB/s", "speedup") | 59 printf("\n%-*s %12s %12s %7s\n", len, "benchmark", "old
MB/s", "new MB/s", "speedup") |
60 printf("%-*s %12s %12s %6sx\n", len, what, | 60 printf("%-*s %12s %12s %6sx\n", len, what, |
61 sprintf("%.2f", oldmb[what]), | 61 sprintf("%.2f", oldmb[what]), |
62 sprintf("%.2f", newmb[what]), | 62 sprintf("%.2f", newmb[what]), |
63 sprintf("%.2f", newmb[what]/oldmb[what])) | 63 sprintf("%.2f", newmb[what]/oldmb[what])) |
64 } | 64 } |
65 } | 65 } |
66 ' "$@" | 66 ' "$@" |
OLD | NEW |