From 8a39ee361feb9bf46d728ff1ba4f07ca1d9610b1 Mon Sep 17 00:00:00 2001 From: Michael Stapelberg Date: Thu, 19 Jun 2014 09:22:53 +0200 Subject: Imported Upstream version 1.3 --- misc/benchcmp | 127 ++-------------------------------------------------------- 1 file changed, 4 insertions(+), 123 deletions(-) (limited to 'misc/benchcmp') diff --git a/misc/benchcmp b/misc/benchcmp index 3180f57ea..28a37392d 100755 --- a/misc/benchcmp +++ b/misc/benchcmp @@ -1,124 +1,5 @@ -#!/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. +#!/bin/bash -case "$1" in --*) - echo 'usage: benchcmp old.txt new.txt' >&2 - echo >&2 - echo 'Each input file should be from:' >&2 - echo ' go test -test.run=NONE -test.bench=. > [old,new].txt' >&2 - echo >&2 - echo 'Benchcmp compares the first and last for each benchmark.' >&2 - echo >&2 - echo 'If -test.benchmem=true is added to the "go test" command' >&2 - echo 'benchcmp will also compare memory allocations.' >&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 - - # allocs/op might be at $8 or $10 depending on if - # SetBytes was used or not. - # 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") { - newbytes[$1] = $7 - newalloc[$1] = $9 - } - } else { - old[$1] = $3 - if($6 == "MB/s") - oldmb[$1] = $5 - if($8 == "allocs/op") { - oldbytes[$1] = $5 - oldalloc[$1] = $7 - } - if($10 == "allocs/op") { - oldbytes[$1] = $7 - oldalloc[$1] = $9 - } - } -} - -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&2 +echo ' go get -u code.google.com/p/go.tools/cmd/benchcmp' >&2 +exit 2 -- cgit v1.2.3