MCPcopy Create free account
hub / github.com/dustinxie/lockfree / BenchmarkLockfreeStack

Function BenchmarkLockfreeStack

stack_test.go:55–73  ·  view source on GitHub ↗
(b *testing.B)

Source from the content-addressed store, hash-verified

53}
54
55func BenchmarkLockfreeStack(b *testing.B) {
56 for i := 0; i < b.N; i++ {
57 s := NewStack()
58 wg := sync.WaitGroup{}
59 wg.Add(10)
60 for i := 0; i < 10; i++ {
61 go func(start, end int) {
62 for i := start; i < end; i++ {
63 s.Push(i)
64 }
65 for i := start; i < end; i++ {
66 s.Pop()
67 }
68 wg.Done()
69 }(i*10000, (i+1)*10000)
70 }
71 wg.Wait()
72 }
73}
74
75func BenchmarkStackAndRWMutex(b *testing.B) {
76 for i := 0; i < b.N; i++ {

Callers

nothing calls this directly

Calls 3

PushMethod · 0.95
PopMethod · 0.95
NewStackFunction · 0.70

Tested by

no test coverage detected