snowflake/flake_test.go
2016-05-25 14:57:33 -05:00

45 lines
777 B
Go

package flake
import (
"testing"
)
//////////////////////////////////////////////////////////////////////////////
// Benchmarks Presence Update event with fake data.
func BenchmarkGenerate(b *testing.B) {
node, _ := NewFlakeNode(1)
b.ReportAllocs()
for n := 0; n < b.N; n++ {
_, _ = node.Generate()
}
}
// Benchmarks Presence Update event with fake data.
func BenchmarkGenerateLocks(b *testing.B) {
node, _ := NewFlakeNode(1)
b.ReportAllocs()
for n := 0; n < b.N; n++ {
_, _ = node.LockedGenerate()
}
}
// Benchmarks Presence Update event with fake data.
func BenchmarkGenerateLocksParallel(b *testing.B) {
node, _ := NewFlakeNode(1)
b.ReportAllocs()
b.RunParallel(func(pb *testing.PB) {
for pb.Next() {
_, _ = node.LockedGenerate()
}
})
}