diff --git a/misc/benchcmp b/misc/benchcmp new file mode 100755 index 0000000000..110c3429e3 --- /dev/null +++ b/misc/benchcmp @@ -0,0 +1,66 @@ +#!/bin/sh +# Copyright 2011 The Go Authors. All rights reserved. +# Use of this source code is governed by a BSD-style +# license that can be found in the LICENSE file. + +case "$1" in +-*) + echo 'usage: benchcmp old.txt new.txt' >&2 + echo >&2 + echo 'Each input file should be gotest -bench output.' >&2 + echo 'Benchcmp compares the first and last for each benchmark.' >&2 + exit 2 +esac + +awk ' +BEGIN { + n = 0 +} + +$1 ~ /^Benchmark/ && $4 == "ns/op" { + if(old[$1]) { + if(!saw[$1]++) { + name[n++] = $1 + if(length($1) > len) + len = length($1) + } + new[$1] = $3 + if($6 == "MB/s") + newmb[$1] = $5 + } else { + old[$1] = $3 + if($6 = "MB/s") + oldmb[$1] = $5 + } +} + +END { + if(n == 0) { + print "benchcmp: no repeated benchmarks" >"/dev/stderr" + exit 1 + } + + printf("%-*s %12s %12s %7s\n", len, "benchmark", "old ns/op", "new ns/op", "delta") + + # print ns/op + for(i=0; i