I've changed : if n < uint64(b.N) { to: if n == 0 { because ...
11 years, 4 months ago
(2014-02-24 16:22:41 UTC)
#2
I've changed :
if n < uint64(b.N) {
to:
if n == 0 {
because a benchmark can exit early due to failures.
Strictly saying, n == 0 is also possible if all worker goroutines exit due to
failures before first pb.Next call. But I think it's still useful diagnostic.
https://codereview.appspot.com/68030043/diff/80001/src/pkg/testing/benchmark.go File src/pkg/testing/benchmark.go (right): https://codereview.appspot.com/68030043/diff/80001/src/pkg/testing/benchmark.go#newcode421 src/pkg/testing/benchmark.go:421: b.Fatal("RunParallel body does not call PB.Next") On 2014/02/24 16:30:51, ...
11 years, 4 months ago
(2014-02-24 16:32:08 UTC)
#4
https://codereview.appspot.com/68030043/diff/120001/src/pkg/testing/benchmark.go File src/pkg/testing/benchmark.go (right): https://codereview.appspot.com/68030043/diff/120001/src/pkg/testing/benchmark.go#newcode420 src/pkg/testing/benchmark.go:420: if n == 0 { Seems like this can ...
11 years, 4 months ago
(2014-02-24 16:52:02 UTC)
#6
https://codereview.appspot.com/68030043/diff/120001/src/pkg/testing/benchmark.go File src/pkg/testing/benchmark.go (right): https://codereview.appspot.com/68030043/diff/120001/src/pkg/testing/benchmark.go#newcode420 src/pkg/testing/benchmark.go:420: if n == 0 { On 2014/02/24 16:52:02, rsc ...
11 years, 4 months ago
(2014-02-24 16:57:04 UTC)
#7
Message was sent while issue was closed.
https://codereview.appspot.com/68030043/diff/120001/src/pkg/testing/benchmark.go
File src/pkg/testing/benchmark.go (right):
https://codereview.appspot.com/68030043/diff/120001/src/pkg/testing/benchmark...
src/pkg/testing/benchmark.go:420: if n == 0 {
On 2014/02/24 16:52:02, rsc wrote:
> Seems like this can be strengthened.
>
> if n < b.N && !b.Failed() {
agree
> b.Fatal("RunParallel body did not complete execution")
> }
this may be non-actionable for newcomers
to be explicit this is to protect against:
b.RunParallel(func(pb *testing.PB) {
doSomething()
})
can you please suggest a rephrasing that mentions PB.Next (maybe an addition in
brackets)?
Issue 68030043: code review 68030043: testing: diagnose a potential misuse of RunParallel
(Closed)
Created 11 years, 4 months ago by dvyukov
Modified 11 years, 4 months ago
Reviewers: rsc, gobot
Base URL:
Comments: 4