mirror of
https://github.com/golang/go.git
synced 2025-12-08 06:10:04 +00:00
runtime: use RunParallel in more benchmarks
LGTM=bradfitz R=golang-codereviews, bradfitz CC=golang-codereviews https://golang.org/cl/68020043
This commit is contained in:
parent
bb9531e11b
commit
69257d17fe
4 changed files with 50 additions and 123 deletions
|
|
@ -370,24 +370,11 @@ func TestSchedLocalQueueSteal(t *testing.T) {
|
|||
}
|
||||
|
||||
func benchmarkStackGrowth(b *testing.B, rec int) {
|
||||
const CallsPerSched = 1000
|
||||
procs := runtime.GOMAXPROCS(-1)
|
||||
N := int32(b.N / CallsPerSched)
|
||||
c := make(chan bool, procs)
|
||||
for p := 0; p < procs; p++ {
|
||||
go func() {
|
||||
for atomic.AddInt32(&N, -1) >= 0 {
|
||||
runtime.Gosched()
|
||||
for g := 0; g < CallsPerSched; g++ {
|
||||
stackGrowthRecursive(rec)
|
||||
}
|
||||
}
|
||||
c <- true
|
||||
}()
|
||||
}
|
||||
for p := 0; p < procs; p++ {
|
||||
<-c
|
||||
}
|
||||
b.RunParallel(func(pb *testing.PB) {
|
||||
for pb.Next() {
|
||||
stackGrowthRecursive(rec)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
func BenchmarkStackGrowth(b *testing.B) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue