From d7653317afea0f45fdf190c1ba1372b74c7514c8 Mon Sep 17 00:00:00 2001 From: sunnyyssh Date: Wed, 25 Dec 2024 23:00:45 +0300 Subject: [PATCH] Updated benchmarks: Add returning error handling --- middleware/idempotency/locker_test.go | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/middleware/idempotency/locker_test.go b/middleware/idempotency/locker_test.go index 4a0f20217a..3073f007df 100644 --- a/middleware/idempotency/locker_test.go +++ b/middleware/idempotency/locker_test.go @@ -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) + } } }) }) @@ -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) + } } }) })