Play Link: https://play.golang.org/p/YppC11kwyLz
Running this command hangs the program: go test -v -bench=.
*"*** Test killed with quit: ran too long (10m0s)."*
But if I comment out the stop/start timer, it is fine.
I tried both with go1.10 and go1.11. Same result.
I have no other file in that directory.
package mymath
import (
"fmt"
"regexp"
"strconv"
"testing"
)
func square(i int) int {
return i * i
}
func Benchmark_Square(b *testing.B) {
for i := 0; i < b.N; i++ {
b.StopTimer()
// do costly setup
r, _ := regexp.Compile("^[0-9]+,")
s := r.FindStringSubmatch("24,32,56")
first := s[0]
first = first[:len(first)-1]
inp, _ := strconv.ParseInt(first, 10, 64)
b.StartTimer()
square(int(inp))
}
}
--
You received this message because you are subscribed to the Google Groups
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.