Skip to content

Commit

Permalink
messageID: add benchmark for NewSafeID
Browse files Browse the repository at this point in the history
Signed-off-by: Koichi Shiraishi <zchee.io@gmail.com>
  • Loading branch information
zchee committed Feb 14, 2022
1 parent bbab81d commit c01cb38
Showing 1 changed file with 27 additions and 0 deletions.
27 changes: 27 additions & 0 deletions messageID_test.go
@@ -0,0 +1,27 @@
package slack

import (
"testing"
)

var id int

func BenchmarkNewSafeID(b *testing.B) {
b.ReportAllocs()

idgen := NewSafeID(1)
for i := 0; i < b.N; i++ {
id = idgen.Next()
}
}

func BenchmarkNewSafeIDParallel(b *testing.B) {
b.ReportAllocs()

b.RunParallel(func(pb *testing.PB) {
for pb.Next() {
idgen := NewSafeID(1)
id = idgen.Next()
}
})
}

0 comments on commit c01cb38

Please sign in to comment.