mirror of https://github.com/k3s-io/k3s
Merge pull request #64370 from idealhack/sub-benchmarks/apiserver/secretbox
Automatic merge from submit-queue (batch tested with PRs 64322, 64210, 64458, 64232, 64370). If you want to cherry-pick this change to another branch, please follow the instructions <a href="https://github.com/kubernetes/community/blob/master/contributors/devel/cherry-picks.md">here</a>. apiserver: update tests to use sub-benchmarks (secretbox_test.go) **What this PR does / why we need it**: Go 1.7 added the subtest feature which can make table-driven tests much easier to run and debug. Some tests are not using this feature. Further reading: [Using Subtests and Sub-benchmarks](https://blog.golang.org/subtests) /kind cleanup **Release note**: ```release-note NONE ```pull/8/head
commit
99ebcd94c9
|
@ -77,12 +77,39 @@ func TestSecretboxKeyRotation(t *testing.T) {
|
|||
}
|
||||
}
|
||||
|
||||
func BenchmarkSecretboxRead_32_1024(b *testing.B) { benchmarkSecretboxRead(b, 32, 1024, false) }
|
||||
func BenchmarkSecretboxRead_32_16384(b *testing.B) { benchmarkSecretboxRead(b, 32, 16384, false) }
|
||||
func BenchmarkSecretboxRead_32_16384_Stale(b *testing.B) { benchmarkSecretboxRead(b, 32, 16384, true) }
|
||||
func BenchmarkSecretboxRead(b *testing.B) {
|
||||
tests := []struct {
|
||||
keyLength int
|
||||
valueLength int
|
||||
expectStale bool
|
||||
}{
|
||||
{keyLength: 32, valueLength: 1024, expectStale: false},
|
||||
{keyLength: 32, valueLength: 16384, expectStale: false},
|
||||
{keyLength: 32, valueLength: 16384, expectStale: true},
|
||||
}
|
||||
for _, t := range tests {
|
||||
name := fmt.Sprintf("%vKeyLength/%vValueLength/%vExpectStale", t.keyLength, t.valueLength, t.expectStale)
|
||||
b.Run(name, func(b *testing.B) {
|
||||
benchmarkSecretboxRead(b, t.keyLength, t.valueLength, t.expectStale)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func BenchmarkSecretboxWrite_32_1024(b *testing.B) { benchmarkSecretboxWrite(b, 32, 1024) }
|
||||
func BenchmarkSecretboxWrite_32_16384(b *testing.B) { benchmarkSecretboxWrite(b, 32, 16384) }
|
||||
func BenchmarkSecretboxWrite(b *testing.B) {
|
||||
tests := []struct {
|
||||
keyLength int
|
||||
valueLength int
|
||||
}{
|
||||
{keyLength: 32, valueLength: 1024},
|
||||
{keyLength: 32, valueLength: 16384},
|
||||
}
|
||||
for _, t := range tests {
|
||||
name := fmt.Sprintf("%vKeyLength/%vValueLength", t.keyLength, t.valueLength)
|
||||
b.Run(name, func(b *testing.B) {
|
||||
benchmarkSecretboxWrite(b, t.keyLength, t.valueLength)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func benchmarkSecretboxRead(b *testing.B, keyLength int, valueLength int, expectStale bool) {
|
||||
p := value.NewPrefixTransformers(nil,
|
||||
|
|
Loading…
Reference in New Issue