v.io/x/ref/test/benchmark: update to be compatible with go1.5
go 1.5 now defaults to using all of the available CPUs for tests
rather than just one. This means that test/benchmark names will
always have -#cpus suffic when run on a multiproc machine. The
util_test.go tests are not following this convention and this
change modifies them so that they do.
Change-Id: Ic39a8b4d7275c4cb91b8d3e21b620b31102b7824
diff --git a/test/benchmark/util.go b/test/benchmark/util.go
index 98f0967..a288151 100644
--- a/test/benchmark/util.go
+++ b/test/benchmark/util.go
@@ -62,7 +62,6 @@
if procs != 1 {
benchName = fmt.Sprintf("%s-%d", benchName, procs)
}
-
stats := NewStats(numBuckets)
if injectCond != nil {
diff --git a/test/benchmark/util_test.go b/test/benchmark/util_test.go
index abac396..0da0c3f 100644
--- a/test/benchmark/util_test.go
+++ b/test/benchmark/util_test.go
@@ -10,6 +10,7 @@
"io"
"os"
"regexp"
+ "runtime"
"strings"
"testing"
"time"
@@ -33,6 +34,14 @@
}
}
+func benchmarkName(name string) string {
+ procs := runtime.GOMAXPROCS(-1)
+ if procs != 1 {
+ return fmt.Sprintf("%s-%d", name, procs)
+ }
+ return name
+}
+
func TestStatsInjection(t *testing.T) {
stdout := os.Stdout
r, w, _ := os.Pipe()
@@ -48,11 +57,11 @@
startStatsInjector()
- fmt.Printf("%s\t", "BenchmarkTest")
+ fmt.Printf("%s\t", benchmarkName("BenchmarkTest"))
result := testing.Benchmark(BenchmarkTest)
fmt.Println(result.String())
- fmt.Printf("%s\t", "BenchmarkTestMulti")
+ fmt.Printf("%s\t", benchmarkName("BenchmarkTestMulti"))
result = testing.Benchmark(BenchmarkTestMulti)
fmt.Println(result.String())