Add BenchmarkGenerateMaxSequence func

This allows a benchmark showing how fast ids can be generated with 21
bits assigned to the sequence number
This commit is contained in:
Bruce Marriner 2019-04-10 01:32:30 +00:00
parent 0de6e0c074
commit 267d02f8b9

View File

@ -169,6 +169,20 @@ func BenchmarkGenerate(b *testing.B) {
} }
} }
func BenchmarkGenerateMaxSequence(b *testing.B) {
NodeBits = 1
StepBits = 21
node, _ := NewNode(1)
b.ReportAllocs()
b.ResetTimer()
for n := 0; n < b.N; n++ {
_ = node.Generate()
}
}
func BenchmarkUnmarshal(b *testing.B) { func BenchmarkUnmarshal(b *testing.B) {
// Generate the ID to unmarshal // Generate the ID to unmarshal
node, _ := NewNode(1) node, _ := NewNode(1)