| 3754 | } |
| 3755 | |
| 3756 | func BenchmarkInPlaceArrayUnions(b *testing.B) { |
| 3757 | rand.Seed(100) |
| 3758 | b.ReportAllocs() |
| 3759 | componentBitmaps := make([]*Bitmap, 100) |
| 3760 | for i := 0; i < 100; i++ { |
| 3761 | bitmap := NewBitmap() |
| 3762 | for j := 0; j < 100; j++ { |
| 3763 | // keep all entries in [0,4096), so they stay arrays. |
| 3764 | bitmap.Add(uint32(rand.Intn(arrayDefaultMaxSize))) |
| 3765 | } |
| 3766 | componentBitmaps[i] = bitmap |
| 3767 | } |
| 3768 | b.ResetTimer() |
| 3769 | for i := 0; i < b.N; i++ { |
| 3770 | bitmap := NewBitmap() |
| 3771 | for j := 0; j < 100; j++ { |
| 3772 | bitmap.Or(componentBitmaps[rand.Intn(100)]) |
| 3773 | } |
| 3774 | } |
| 3775 | } |
| 3776 | |
| 3777 | func BenchmarkAntagonisticArrayUnionsGrowth(b *testing.B) { |
| 3778 | left := NewBitmap() |