aboutsummaryrefslogtreecommitdiff
path: root/src/testing/benchmark.go
diff options
context:
space:
mode:
authorJean de Klerk <deklerk@google.com>2018-07-31 18:10:42 -0700
committerIan Lance Taylor <iant@golang.org>2019-10-22 19:21:02 +0000
commita813d3c788b4ec58032616e8d269ee65d1b10085 (patch)
treeae82b1d8b5b6b18b5c474b9b62cae270e2fbe30d /src/testing/benchmark.go
parent7416315e3358b0bc2774c92f39d8f7c4b33790ad (diff)
downloadgo-a813d3c788b4ec58032616e8d269ee65d1b10085.tar.xz
testing: stream log output in verbose mode
Fixes #24929 Change-Id: Icc426068cd73b75b78001f55e1e5d81ccebbe854 Reviewed-on: https://go-review.googlesource.com/c/go/+/127120 Run-TryBot: Ian Lance Taylor <iant@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org>
Diffstat (limited to 'src/testing/benchmark.go')
-rw-r--r--src/testing/benchmark.go22
1 files changed, 21 insertions, 1 deletions
diff --git a/src/testing/benchmark.go b/src/testing/benchmark.go
index 0e348be358..e954fc6ccb 100644
--- a/src/testing/benchmark.go
+++ b/src/testing/benchmark.go
@@ -545,7 +545,11 @@ func (ctx *benchContext) processBench(b *B) {
for j := uint(0); j < *count; j++ {
runtime.GOMAXPROCS(procs)
benchName := benchmarkName(b.name, procs)
- fmt.Fprintf(b.w, "%-*s\t", ctx.maxLen, benchName)
+
+ // If it's chatty, we've already printed this information.
+ if !b.chatty {
+ fmt.Fprintf(b.w, "%-*s\t", ctx.maxLen, benchName)
+ }
// Recompute the running time for all but the first iteration.
if i > 0 || j > 0 {
b = &B{
@@ -569,6 +573,9 @@ func (ctx *benchContext) processBench(b *B) {
continue
}
results := r.String()
+ if b.chatty {
+ fmt.Fprintf(b.w, "%-*s\t", ctx.maxLen, benchName)
+ }
if *benchmarkMemory || b.showAllocResult {
results += "\t" + r.MemString()
}
@@ -627,6 +634,19 @@ func (b *B) Run(name string, f func(b *B)) bool {
// Only process sub-benchmarks, if any.
atomic.StoreInt32(&sub.hasSub, 1)
}
+
+ if b.chatty {
+ labelsOnce.Do(func() {
+ fmt.Printf("goos: %s\n", runtime.GOOS)
+ fmt.Printf("goarch: %s\n", runtime.GOARCH)
+ if b.importPath != "" {
+ fmt.Printf("pkg: %s\n", b.importPath)
+ }
+ })
+
+ fmt.Println(benchName)
+ }
+
if sub.run1() {
sub.run()
}