From 267d02f8b9813a5375a1b8b58ff051a8c245ca8b Mon Sep 17 00:00:00 2001 From: Bruce Marriner Date: Wed, 10 Apr 2019 01:32:30 +0000 Subject: [PATCH] Add BenchmarkGenerateMaxSequence func This allows a benchmark showing how fast ids can be generated with 21 bits assigned to the sequence number --- snowflake_test.go | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/snowflake_test.go b/snowflake_test.go index 18f5d9f..3d84763 100644 --- a/snowflake_test.go +++ b/snowflake_test.go @@ -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) { // Generate the ID to unmarshal node, _ := NewNode(1)