Add benchmarks for serializing PodList
This commit is contained in:
@@ -27,7 +27,7 @@ import (
|
||||
|
||||
jsoniter "github.com/json-iterator/go"
|
||||
appsv1 "k8s.io/api/apps/v1"
|
||||
"k8s.io/api/core/v1"
|
||||
v1 "k8s.io/api/core/v1"
|
||||
"k8s.io/apimachinery/pkg/api/apitesting/fuzzer"
|
||||
"k8s.io/apimachinery/pkg/api/apitesting/roundtrip"
|
||||
apiequality "k8s.io/apimachinery/pkg/api/equality"
|
||||
@@ -424,6 +424,25 @@ func benchmarkItems(b *testing.B) []v1.Pod {
|
||||
return items
|
||||
}
|
||||
|
||||
func benchmarkItemsList(b *testing.B, numItems int) v1.PodList {
|
||||
apiObjectFuzzer := fuzzer.FuzzerFor(FuzzerFuncs, rand.NewSource(benchmarkSeed), legacyscheme.Codecs)
|
||||
items := make([]v1.Pod, numItems)
|
||||
for i := range items {
|
||||
var pod api.Pod
|
||||
apiObjectFuzzer.Fuzz(&pod)
|
||||
pod.Spec.InitContainers, pod.Status.InitContainerStatuses = nil, nil
|
||||
out, err := legacyscheme.Scheme.ConvertToVersion(&pod, v1.SchemeGroupVersion)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
items[i] = *out.(*v1.Pod)
|
||||
}
|
||||
|
||||
return v1.PodList{
|
||||
Items: items,
|
||||
}
|
||||
}
|
||||
|
||||
// BenchmarkEncodeCodec measures the cost of performing a codec encode, which includes
|
||||
// reflection (to clear APIVersion and Kind)
|
||||
func BenchmarkEncodeCodec(b *testing.B) {
|
||||
|
Reference in New Issue
Block a user