request for a benchmark
cupen opened this issue · comments
咚咔 commented
my benchmark result.
BenchmarkMustNewID-8 50000 38982 ns/op 0 B/op
var snowflake *sonyflake.Sonyflake
func init() {
st := sonyflake.Settings{
StartTime: time.Date(2019, 07, 29, 15, 43, 0, 0, time.Local),
CheckMachineID: func(machineId uint16) bool {
return true
},
}
snowflake = sonyflake.NewSonyflake(st)
if snowflake == nil {
err := fmt.Errorf("Invalid snowflake settings %v", st)
panic(err)
}
}
func MustNewID() uint64 {
id, err := snowflake.NextID()
if err != nil {
panic(err)
}
return id
}
func BenchmarkMustNewID(b *testing.B) {
for i := 0; i < b.N; i++ {
MustNewID()
}
}