mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-23 11:50:44 +00:00
Add benchmark for random string generation utility
This commit is contained in:
parent
c279a53ca0
commit
0185e55889
@ -24,6 +24,7 @@ import (
|
|||||||
|
|
||||||
const (
|
const (
|
||||||
maxRangeTestCount = 500
|
maxRangeTestCount = 500
|
||||||
|
testStringLength = 32
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestString(t *testing.T) {
|
func TestString(t *testing.T) {
|
||||||
@ -99,3 +100,15 @@ func TestInt63nRange(t *testing.T) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func BenchmarkRandomStringGeneration(b *testing.B) {
|
||||||
|
b.ResetTimer()
|
||||||
|
var s string
|
||||||
|
for i := 0; i < b.N; i++ {
|
||||||
|
s = String(testStringLength)
|
||||||
|
}
|
||||||
|
b.StopTimer()
|
||||||
|
if len(s) == 0 {
|
||||||
|
b.Fatal(s)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user