Benchmark_MemoryLock_Parallel() — fiber Function Reference
Architecture documentation for the Benchmark_MemoryLock_Parallel() function in locker_test.go from the fiber codebase.
Entity Profile
Dependency Diagram
graph TD b069f310_01ad_987a_3a50_770b2a86f299["Benchmark_MemoryLock_Parallel()"] 40783155_a178_0f0d_045d_88e980e329eb["locker_test.go"] b069f310_01ad_987a_3a50_770b2a86f299 -->|defined in| 40783155_a178_0f0d_045d_88e980e329eb style b069f310_01ad_987a_3a50_770b2a86f299 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
middleware/idempotency/locker_test.go lines 105–150
func Benchmark_MemoryLock_Parallel(b *testing.B) {
// In order to prevent using repeated keys I pre-allocate keys
keys := make([]string, 1_000_000)
for i := range keys {
keys[i] = strconv.Itoa(i)
}
b.Run("UniqueKeys", func(b *testing.B) {
lock := idempotency.NewMemoryLock()
var keyI atomic.Int32
b.ReportAllocs()
b.ResetTimer()
b.RunParallel(func(p *testing.PB) {
for p.Next() {
i := int(keyI.Add(1)) % len(keys)
key := keys[i]
if err := lock.Lock(key); err != nil {
b.Fatal(err)
}
if err := lock.Unlock(key); err != nil {
b.Fatal(err)
}
}
})
})
b.Run("RepeatedKeys", func(b *testing.B) {
lock := idempotency.NewMemoryLock()
var keyI atomic.Int32
b.ReportAllocs()
b.ResetTimer()
b.RunParallel(func(p *testing.PB) {
for p.Next() {
// Division by 3 ensures that index will be repeated exactly 3 times
i := int(keyI.Add(1)) / 3 % len(keys)
key := keys[i]
if err := lock.Lock(key); err != nil {
b.Fatal(err)
}
if err := lock.Unlock(key); err != nil {
b.Fatal(err)
}
}
})
})
}
Domain
Subdomains
Defined In
Source
Frequently Asked Questions
What does Benchmark_MemoryLock_Parallel() do?
Benchmark_MemoryLock_Parallel() is a function in the fiber codebase, defined in middleware/idempotency/locker_test.go.
Where is Benchmark_MemoryLock_Parallel() defined?
Benchmark_MemoryLock_Parallel() is defined in middleware/idempotency/locker_test.go at line 105.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free