Commit 51b9879a authored by Dmitriy Vyukov's avatar Dmitriy Vyukov

math/big: use RunParallel in benchmarks

LGTM=bradfitz
R=golang-codereviews, bradfitz
CC=golang-codereviews
https://golang.org/cl/67830044
parent 44cc8e5c
......@@ -437,20 +437,11 @@ func BenchmarkStringPiParallel(b *testing.B) {
if x.decimalString() != pi {
panic("benchmark incorrect: conversion failed")
}
n := runtime.GOMAXPROCS(0)
m := b.N / n // n*m <= b.N due to flooring, but the error is neglibible (n is not very large)
c := make(chan int, n)
for i := 0; i < n; i++ {
go func() {
for j := 0; j < m; j++ {
x.decimalString()
}
c <- 0
}()
}
for i := 0; i < n; i++ {
<-c
}
b.RunParallel(func(pb *testing.PB) {
for pb.Next() {
x.decimalString()
}
})
}
func BenchmarkScan10Base2(b *testing.B) { ScanHelper(b, 2, 10, 10) }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment