MCPcopy Index your code
hub / github.com/deepflowio/deepflow / BenchmarkLockFreePoolGetPut2Thread

Function BenchmarkLockFreePoolGetPut2Thread

server/libs/pool/pool_test.go:105–127  ·  view source on GitHub ↗
(b *testing.B)

Source from the content-addressed store, hash-verified

103}
104
105func BenchmarkLockFreePoolGetPut2Thread(b *testing.B) {
106 pools := make([]*LockFreePool[int], 16)
107 for i := range pools {
108 pool := NewLockFreePool(func() int { return 0 })
109 pools[i] = pool
110 }
111
112 put := func(pool []*LockFreePool[int]) {
113 for i := 0; i < b.N; i++ {
114 for _, p := range pools {
115 p.Put(0)
116 }
117 }
118 }
119
120 b.ResetTimer()
121 go put(pools)
122 for i := 0; i < b.N; i++ {
123 for _, p := range pools {
124 p.Get()
125 }
126 }
127}
128
129func BenchmarkLockFreePoolHungryGet(b *testing.B) {
130 pool := NewLockFreePool[int](func() int { return 0 })

Callers

nothing calls this directly

Calls 3

NewLockFreePoolFunction · 0.85
PutMethod · 0.65
GetMethod · 0.65

Tested by

no test coverage detected