Commits

Anonymous committed be4b5d1

math/big: use RunParallel in benchmarks

LGTM=bradfitz
R=golang-codereviews, bradfitz
CC=golang-codereviews
https://codereview.appspot.com/67830044

Comments (0)

Files changed (1)

src/pkg/math/big/nat_test.go

 	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) }