mirror of
https://github.com/golang/go
synced 2024-11-23 15:40:06 -07:00
math/big: use RunParallel in benchmarks
LGTM=bradfitz R=golang-codereviews, bradfitz CC=golang-codereviews https://golang.org/cl/67830044
This commit is contained in:
parent
44cc8e5cc9
commit
51b9879a90
@ -437,20 +437,11 @@ func BenchmarkStringPiParallel(b *testing.B) {
|
|||||||
if x.decimalString() != pi {
|
if x.decimalString() != pi {
|
||||||
panic("benchmark incorrect: conversion failed")
|
panic("benchmark incorrect: conversion failed")
|
||||||
}
|
}
|
||||||
n := runtime.GOMAXPROCS(0)
|
b.RunParallel(func(pb *testing.PB) {
|
||||||
m := b.N / n // n*m <= b.N due to flooring, but the error is neglibible (n is not very large)
|
for pb.Next() {
|
||||||
c := make(chan int, n)
|
x.decimalString()
|
||||||
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
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func BenchmarkScan10Base2(b *testing.B) { ScanHelper(b, 2, 10, 10) }
|
func BenchmarkScan10Base2(b *testing.B) { ScanHelper(b, 2, 10, 10) }
|
||||||
|
Loading…
Reference in New Issue
Block a user