Side by Side Diff: src/pkg/sync/once_test.go
Issue 96910043 :
code review 96910043: testing: RunParallel and SetParallelism are misleading. (Closed)
Patch Set: diff -r 7f529f73708a http://code.google.com/p/go
Use n/p to move between diff chunks;
N/P to move between comments.
Please Sign in to add in-line comments.
Jump to:
src/pkg/fmt/fmt_test.go
src/pkg/math/big/nat_test.go
src/pkg/net/http/serve_test.go
src/pkg/net/rpc/server_test.go
src/pkg/runtime/chan_test.go
src/pkg/runtime/mfinal_test.go
src/pkg/runtime/norace_test.go
src/pkg/runtime/proc_test.go
src/pkg/sync/mutex_test.go
src/pkg/sync/once_test.go
src/pkg/sync/pool_test.go
src/pkg/sync/runtime_sema_test.go
src/pkg/sync/rwmutex_test.go
src/pkg/sync/waitgroup_test.go
src/pkg/testing/benchmark.go
src/pkg/testing/benchmark_test.go
src/pkg/time/sleep_test.go
OLD NEW
1 // Copyright 2009 The Go Authors. All rights reserved. 1 // Copyright 2009 The Go Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style 2 // Use of this source code is governed by a BSD-style
3 // license that can be found in the LICENSE file. 3 // license that can be found in the LICENSE file.
4 4
5 package sync_test 5 package sync_test
6 6
7 import ( 7 import (
8 . "sync" 8 . "sync"
9 "testing" 9 "testing"
10 ) 10 )
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading...
55 } 55 }
56 once.Do(func() {}) 56 once.Do(func() {})
57 once.Do(func() { 57 once.Do(func() {
58 t.Fatalf("Once called twice") 58 t.Fatalf("Once called twice")
59 }) 59 })
60 } 60 }
61 61
62 func BenchmarkOnce(b *testing.B) { 62 func BenchmarkOnce(b *testing.B) {
63 var once Once 63 var once Once
64 f := func() {} 64 f := func() {}
65 » b.RunParallel (func(pb *testing.PB) { 65 » b.RunConcurrent (func(pb *testing.PB) {
66 for pb.Next() { 66 for pb.Next() {
67 once.Do(f) 67 once.Do(f)
68 } 68 }
69 }) 69 })
70 } 70 }
OLD NEW