Index: src/pkg/testing/benchmark.go |
=================================================================== |
--- a/src/pkg/testing/benchmark.go |
+++ b/src/pkg/testing/benchmark.go |
@@ -43,7 +43,7 @@ |
timerOn bool |
showAllocResult bool |
result BenchmarkResult |
- parallelism int // RunParallel creates parallelism*GOMAXPROCS goroutines |
+ concurrency int // RunConcurrent creates concurrency*GOMAXPROCS goroutines |
// The initial states of memStats.Mallocs and memStats.TotalAlloc. |
startAllocs uint64 |
startBytes uint64 |
@@ -118,7 +118,7 @@ |
// by clearing garbage from previous runs. |
runtime.GC() |
b.N = n |
- b.parallelism = 1 |
+ b.concurrency = 1 |
b.ResetTimer() |
b.StartTimer() |
b.benchmark.F(b) |
@@ -350,7 +350,7 @@ |
} |
} |
-// A PB is used by RunParallel for running parallel benchmarks. |
+// A PB is used by RunConcurrent for running parallel benchmarks. |
type PB struct { |
globalN *uint64 // shared between all worker goroutines iteration counter |
grain uint64 // acquire that many iterations from globalN at once |
@@ -374,17 +374,20 @@ |
return true |
} |
-// RunParallel runs a benchmark in parallel. |
-// It creates multiple goroutines and distributes b.N iterations among them. |
-// The number of goroutines defaults to GOMAXPROCS. To increase parallelism for |
-// non-CPU-bound benchmarks, call SetParallelism before RunParallel. |
-// RunParallel is usually used with the go test -cpu flag. |
+// RunConcurrent distributes benchmark runs among a set of goroutines. |
+// RunConcurrent measures how a benchmark scales with increasing concurrecy. It |
+// is usually used with the go test -cpu flag to measure scaling with increasing |
+// parallelism. |
+// |
+// By default, RunConcurrent creates GOMAXPROCS goroutines and distributes b.N |
+// iterations among them. The number of goroutines can be changed by calling |
+// SetConcurrency before running RunConcurrent. |
// |
// The body function will be run in each goroutine. It should set up any |
// goroutine-local state and then iterate until pb.Next returns false. |
// It should not use the StartTimer, StopTimer, or ResetTimer functions, |
// because they have global effect. |
-func (b *B) RunParallel(body func(*PB)) { |
+func (b *B) RunConcurrent(body func(*PB)) { |
// Calculate grain size as number of iterations that take ~100µs. |
// 100µs is enough to amortize the overhead and provide sufficient |
// dynamic load balancing. |
@@ -402,7 +405,7 @@ |
} |
n := uint64(0) |
- numProcs := b.parallelism * runtime.GOMAXPROCS(0) |
+ numProcs := b.concurrency * runtime.GOMAXPROCS(0) |
var wg sync.WaitGroup |
wg.Add(numProcs) |
for p := 0; p < numProcs; p++ { |
@@ -418,16 +421,16 @@ |
} |
wg.Wait() |
if n <= uint64(b.N) && !b.Failed() { |
- b.Fatal("RunParallel: body exited without pb.Next() == false") |
+ b.Fatal("RunConcurrent: body exited without pb.Next() == false") |
} |
} |
-// SetParallelism sets the number of goroutines used by RunParallel to p*GOMAXPROCS. |
-// There is usually no need to call SetParallelism for CPU-bound benchmarks. |
-// If p is less than 1, this call will have no effect. |
-func (b *B) SetParallelism(p int) { |
+// SetConcurrency sets the number of goroutines used by RunConcurrent to |
+// p*GOMAXPROCS. There is usually no need to call SetConcurrency for CPU-bound |
+// benchmarks. If p is less than 1, this call will have no effect. |
+func (b *B) SetConcurrency(p int) { |
if p >= 1 { |
- b.parallelism = p |
+ b.concurrency = p |
} |
} |