github.com/Uhtred009/v2ray-core-1@v4.31.2+incompatible/common/dice/dice_test.go (about)

     1  package dice_test
     2  
     3  import (
     4  	"math/rand"
     5  	"testing"
     6  
     7  	. "v2ray.com/core/common/dice"
     8  )
     9  
    10  func BenchmarkRoll1(b *testing.B) {
    11  	for i := 0; i < b.N; i++ {
    12  		Roll(1)
    13  	}
    14  }
    15  
    16  func BenchmarkRoll20(b *testing.B) {
    17  	for i := 0; i < b.N; i++ {
    18  		Roll(20)
    19  	}
    20  }
    21  
    22  func BenchmarkIntn1(b *testing.B) {
    23  	for i := 0; i < b.N; i++ {
    24  		rand.Intn(1)
    25  	}
    26  }
    27  
    28  func BenchmarkIntn20(b *testing.B) {
    29  	for i := 0; i < b.N; i++ {
    30  		rand.Intn(20)
    31  	}
    32  }