Skip to content

Commit

Permalink
Benchmark for topology spreading filter
Browse files Browse the repository at this point in the history
Signed-off-by: Aldo Culquicondor <acondor@google.com>
  • Loading branch information
alculquicondor committed Mar 31, 2020
1 parent fce286e commit 275da7a
Showing 1 changed file with 16 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ import (
"k8s.io/client-go/kubernetes/fake"
framework "k8s.io/kubernetes/pkg/scheduler/framework/v1alpha1"
"k8s.io/kubernetes/pkg/scheduler/internal/cache"
"k8s.io/kubernetes/pkg/scheduler/internal/parallelize"
schedulernodeinfo "k8s.io/kubernetes/pkg/scheduler/nodeinfo"
st "k8s.io/kubernetes/pkg/scheduler/testing"
)
Expand Down Expand Up @@ -1065,7 +1066,7 @@ func TestPreFilterStateRemovePod(t *testing.T) {
}
}

func BenchmarkTestCalPreFilterState(b *testing.B) {
func BenchmarkFilter(b *testing.B) {
tests := []struct {
name string
pod *v1.Pod
Expand Down Expand Up @@ -1103,17 +1104,30 @@ func BenchmarkTestCalPreFilterState(b *testing.B) {
},
}
for _, tt := range tests {
var state *framework.CycleState
b.Run(tt.name, func(b *testing.B) {
existingPods, allNodes, _ := st.MakeNodesAndPodsForEvenPodsSpread(tt.pod.Labels, tt.existingPodsNum, tt.allNodesNum, tt.filteredNodesNum)
pl := PodTopologySpread{
sharedLister: cache.NewSnapshot(existingPods, allNodes),
}
ctx := context.Background()
b.ResetTimer()
for i := 0; i < b.N; i++ {
s := pl.PreFilter(context.Background(), framework.NewCycleState(), tt.pod)
state = framework.NewCycleState()
s := pl.PreFilter(ctx, state, tt.pod)
if !s.IsSuccess() {
b.Fatal(s.AsError())
}
filterNode := func(i int) {
n, _ := pl.sharedLister.NodeInfos().Get(allNodes[i].Name)
pl.Filter(ctx, state, tt.pod, n)
}
parallelize.Until(ctx, len(allNodes), filterNode)
}
})
b.Run(tt.name+"/Clone", func(b *testing.B) {
for i := 0; i < b.N; i++ {
state.Clone()
}
})
}
Expand Down

0 comments on commit 275da7a

Please sign in to comment.