Skip to content

Commit

Permalink
improve bench
Browse files Browse the repository at this point in the history
  • Loading branch information
travierm committed Apr 28, 2024
1 parent 6e43d4b commit 95d1ceb
Showing 1 changed file with 16 additions and 14 deletions.
30 changes: 16 additions & 14 deletions heap_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -125,20 +125,22 @@ func BenchmarkFindById(b *testing.B) {
}
}

func BenchmarkInsertWithIndex(b *testing.B) {
heap := NewHeap[TestRecord]("products", "storage/test")

for n := 0; n < b.N; n++ {
_ = heap.InsertWithIndex(&Record[TestRecord]{ID: uint64(1), Data: TestRecord{Name: fmt.Sprintf("Product %d", 1), Amount: 100.0}})
}
}

func BenchmarkInsertWithoutIndex(b *testing.B) {
heap := NewHeap[TestRecord]("products", "storage/test")

for n := 0; n < b.N; n++ {
_ = heap.Insert(&Record[TestRecord]{ID: uint64(1), Data: TestRecord{Name: fmt.Sprintf("Product %d", 1), Amount: 100.0}})
}
func BenchmarkInsert(b *testing.B) {
b.Run("insert with index", func(b *testing.B) {
heap := NewHeap[TestRecord]("products", "storage/test")

for n := 0; n < b.N; n++ {
_ = heap.InsertWithIndex(&Record[TestRecord]{ID: uint64(1), Data: TestRecord{Name: fmt.Sprintf("Product %d", 1), Amount: 100.0}})
}
})

b.Run("insert without index", func(b *testing.B) {
heap := NewHeap[TestRecord]("products", "storage/test")

for n := 0; n < b.N; n++ {
_ = heap.Insert(&Record[TestRecord]{ID: uint64(1), Data: TestRecord{Name: fmt.Sprintf("Product %d", 1), Amount: 100.0}})
}
})
}

func BenchmarkFindByIdWithIndexes(b *testing.B) {
Expand Down

0 comments on commit 95d1ceb

Please sign in to comment.