1
0
mirror of https://github.com/v2fly/v2ray-core.git synced 2025-01-02 23:47:07 -05:00

benchmark for dice

This commit is contained in:
Darien Raymond 2018-02-24 13:57:25 +01:00
parent dfd4d397bb
commit 2b4104e491
No known key found for this signature in database
GPG Key ID: 7251FFA14BB18169

32
common/dice/dice_test.go Normal file
View File

@ -0,0 +1,32 @@
package dice_test
import (
"math/rand"
"testing"
. "v2ray.com/core/common/dice"
)
func BenchmarkRoll1(b *testing.B) {
for i := 0; i < b.N; i++ {
Roll(1)
}
}
func BenchmarkRoll20(b *testing.B) {
for i := 0; i < b.N; i++ {
Roll(20)
}
}
func BenchmarkIntn1(b *testing.B) {
for i := 0; i < b.N; i++ {
rand.Intn(1)
}
}
func BenchmarkIntn20(b *testing.B) {
for i := 0; i < b.N; i++ {
rand.Intn(20)
}
}