BenchmarkArrayIorMergeThreshold tests performance when unioning two array containers when the cardinality sum is over 4096
(b *testing.B)
| 3818 | // BenchmarkArrayIorMergeThreshold tests performance |
| 3819 | // when unioning two array containers when the cardinality sum is over 4096 |
| 3820 | func BenchmarkArrayUnionThreshold(b *testing.B) { |
| 3821 | testOddPoint := map[string]int{ |
| 3822 | "mostly-overlap": 4900, |
| 3823 | "little-overlap": 2000, |
| 3824 | "no-overlap": 0, |
| 3825 | } |
| 3826 | for name, oddPoint := range testOddPoint { |
| 3827 | b.Run(name, func(b *testing.B) { |
| 3828 | left := NewBitmap() |
| 3829 | right := NewBitmap() |
| 3830 | for i := 0; i < 5000; i++ { |
| 3831 | if i%2 == 0 { |
| 3832 | left.Add(uint32(i)) |
| 3833 | } |
| 3834 | if i%2 == 0 && i < oddPoint { |
| 3835 | right.Add(uint32(i)) |
| 3836 | } else if i%2 == 1 && i >= oddPoint { |
| 3837 | right.Add(uint32(i)) |
| 3838 | } |
| 3839 | } |
| 3840 | b.ResetTimer() |
| 3841 | b.ReportAllocs() |
| 3842 | for i := 0; i < b.N; i++ { |
| 3843 | right.Clone().Or(left) |
| 3844 | } |
| 3845 | }) |
| 3846 | } |
| 3847 | } |
| 3848 | |
| 3849 | func TestIssue467CaseSmall(t *testing.T) { |
| 3850 | b := New() |