Search code examples
gogo-testing

Go Benchmark Output Format


My function name is BenchmarkArray1 what does the -12 represent?

BenchmarkArray1-12              1000000000               0.826 ns/op

Solution

  • It is supposed to be interpreted as 12 not -12.

    It is the value of GOMAXPROCS environment variable. GOMAXPROCS is a parameter used by the go scheduler to determine how many OS threads may be actively executing Go code simultaneously.

    Its default value is the no. of CPUs in your machine.

    GOMAXPROCS is actually the value of n in, go's m:n scheduling(m go routines running on n operating system threads)