Skip to content

Commit 1e05849

Browse files
committed
Add benchmark for Difference and DifferenceSeq
1 parent 601ea3a commit 1e05849

File tree

1 file changed

+18
-0
lines changed
  • staging/src/k8s.io/apimachinery/pkg/util/sets

1 file changed

+18
-0
lines changed

staging/src/k8s.io/apimachinery/pkg/util/sets/set_test.go

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -420,5 +420,23 @@ func BenchmarkStringSet(b *testing.B) {
420420
randOperand().List()
421421
}
422422
})
423+
b.Run(fmt.Sprintf("difference-%v", here.size), func(b *testing.B) {
424+
b.ReportAllocs()
425+
for b.Loop() {
426+
for item := range randOperand().Difference(randOperand()) {
427+
_ = item
428+
}
429+
}
430+
})
431+
b.Run(fmt.Sprintf("difference-seq-%v", here.size), func(b *testing.B) {
432+
b.ReportAllocs()
433+
for b.Loop() {
434+
s1 := Set[string](randOperand())
435+
s2 := Set[string](randOperand())
436+
for item := range s1.DifferenceSeq(s2) {
437+
_ = item
438+
}
439+
}
440+
})
423441
}
424442
}

0 commit comments

Comments
 (0)