Skip to content

Commit

Permalink
Add a benchmark for PreviousSet and PreviousClear
Browse files Browse the repository at this point in the history
On an Apple M2 they produces these results:

BenchmarkBitsetOps/NextSet-8       	 2537938	       470.0 ns/op
BenchmarkBitsetOps/NextClear-8     	 2564336	       468.1 ns/op
BenchmarkBitsetOps/PreviousSet-8   	   19930	     59924 ns/op
BenchmarkBitsetOps/PreviousClear-8 	   19912	     61002 ns/op

A future commit should improve upon this.
  • Loading branch information
lukesandberg committed Nov 14, 2024
1 parent c77dfc3 commit de30b18
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions bitset_benchmark_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,23 @@ func BenchmarkBitsetOps(b *testing.B) {
}
})

b.Run("PreviousSet", func(b *testing.B) {
s = New(100000)
b.ResetTimer()
for i := 0; i < b.N; i++ {
s.PreviousSet(99999)
}
})

b.Run("PreviousClear", func(b *testing.B) {
s = New(100000)
s.FlipRange(0, 100000)
b.ResetTimer()
for i := 0; i < b.N; i++ {
s.PreviousClear(99999)
}
})

b.Run("DifferenceCardinality", func(b *testing.B) {
empty := New(100000)
b.ResetTimer()
Expand Down

0 comments on commit de30b18

Please sign in to comment.