Skip to content

Commit 0185e55

Browse files
committed
Add benchmark for random string generation utility
1 parent c279a53 commit 0185e55

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

staging/src/k8s.io/apimachinery/pkg/util/rand/rand_test.go

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ import (
2424

2525
const (
2626
maxRangeTestCount = 500
27+
testStringLength = 32
2728
)
2829

2930
func TestString(t *testing.T) {
@@ -99,3 +100,15 @@ func TestInt63nRange(t *testing.T) {
99100
}
100101
}
101102
}
103+
104+
func BenchmarkRandomStringGeneration(b *testing.B) {
105+
b.ResetTimer()
106+
var s string
107+
for i := 0; i < b.N; i++ {
108+
s = String(testStringLength)
109+
}
110+
b.StopTimer()
111+
if len(s) == 0 {
112+
b.Fatal(s)
113+
}
114+
}

0 commit comments

Comments
 (0)