tracker/pkg/prand/prand_test.go

26 lines
325 B
Go
Raw Normal View History

2016-11-07 13:22:27 +01:00
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
})
}