tracker/pkg/prand/prand_test.go
2016-11-30 19:54:57 +01:00

25 lines
325 B
Go

package prand
import (
"math/rand"
"sync/atomic"
"testing"
)
func BenchmarkContainer_GetReturn(b *testing.B) {
c := New(1024)
a := uint64(0)
b.ResetTimer()
b.RunParallel(func(p *testing.PB) {
i := int(atomic.AddUint64(&a, 1))
var r *rand.Rand
for p.Next() {
r = c.Get(i)
c.Return(i)
}
_ = r
})
}