Skip to content

Commit

Permalink
Updated benchmarks: Add returning error handling
Browse files Browse the repository at this point in the history
  • Loading branch information
sunnyyssh committed Dec 25, 2024
1 parent 98d7ae9 commit d765331
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions middleware/idempotency/locker_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -97,8 +97,12 @@ func Benchmark_MemoryLock_Parallel(b *testing.B) {
for p.Next() {
i := int(keyI.Add(1)) % len(keys)
key := keys[i]
lock.Lock(key)
lock.Unlock(key)
if err := lock.Lock(key); err != nil {
b.Fatal(err)
}
if err := lock.Unlock(key); err != nil {
b.Fatal(err)
}
}
})
})
Expand All @@ -111,8 +115,12 @@ func Benchmark_MemoryLock_Parallel(b *testing.B) {
// Division by 3 ensures that index will be repreated exactly 3 times
i := int(keyI.Add(1)) / 3 % len(keys)
key := keys[i]
lock.Lock(key)
lock.Unlock(key)
if err := lock.Lock(key); err != nil {
b.Fatal(err)
}
if err := lock.Unlock(key); err != nil {
b.Fatal(err)
}
}
})
})
Expand Down

0 comments on commit d765331

Please sign in to comment.