Skip to content

Commit

Permalink
sqlite benchmark block location
Browse files Browse the repository at this point in the history
  • Loading branch information
n8maninger committed Mar 27, 2024
1 parent 8795e00 commit 7b4ac91
Showing 1 changed file with 10 additions and 8 deletions.
18 changes: 10 additions & 8 deletions persist/sqlite/blocks_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -84,13 +84,15 @@ func BenchmarkBlockLocation(b *testing.B) {
b.ResetTimer()
b.ReportAllocs()

for i := 0; i < b.N; i++ {
c := cids[i%len(cids)]
bucket, key, err := db.BlockLocation(c)
if err != nil {
b.Fatal(err)
} else if bucket != "test" || key != c.String() {
b.Fatalf("unexpected result: %v %v", bucket, key)
b.RunParallel(func(pb *testing.PB) {
for pb.Next() {
c := cids[frand.Intn(len(cids))]
bucket, key, err := db.BlockLocation(c)
if err != nil {
b.Fatal(err)
} else if bucket != "test" || key != c.String() {
b.Fatalf("unexpected result: %v %v", bucket, key)
}
}
}
})
}

0 comments on commit 7b4ac91

Please sign in to comment.