Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

testing: (*testing.Benchmark).Log always logs #10713

Closed
jeffallen opened this issue May 6, 2015 · 2 comments

Comments

Projects
None yet
3 participants
@jeffallen
Copy link
Contributor

commented May 6, 2015

With this benchmark:

package main
import "testing"
func BenchmarkLog(b *testing.B) {
b.Log("why?")
}

I get this output:

$ go test -bench .
testing: warning: no tests to run
PASS
BenchmarkLog 2000000000 0.00 ns/op
--- BENCH: BenchmarkLog
issue_test.go:6: why?
issue_test.go:6: why?
issue_test.go:6: why?
issue_test.go:6: why?
issue_test.go:6: why?
issue_test.go:6: why?

The docs say, "The text will be printed only if the test fails or the -test.v flag is set."

Why is b.Log logging anyway?

@ianlancetaylor

This comment has been minimized.

Copy link
Contributor

commented May 6, 2015

I think this is a documentation issue. The code says:

        // Unlike with tests, we ignore the -chatty flag and always print output for
        // benchmarks since the output generation time will skew the results.

@ianlancetaylor ianlancetaylor added this to the Go1.5 milestone May 6, 2015

@ianlancetaylor ianlancetaylor changed the title (*testing.Benchmark).Log always logs testing: (*testing.Benchmark).Log always logs May 6, 2015

@robpike robpike closed this in e9827f6 May 6, 2015

@jeffallen

This comment has been minimized.

Copy link
Contributor Author

commented May 7, 2015

Thanks guys. Great service!

@golang golang locked and limited conversation to collaborators Jun 25, 2016

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
You can’t perform that action at this time.