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

Function BenchmarkStackAndRWMutex

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

Source from the content-addressed store, hash-verified

73}
74
75func BenchmarkStackAndRWMutex(b *testing.B) {
76 for i := 0; i < b.N; i++ {
77 q := list.New()
78 lock := sync.RWMutex{}
79 wg := sync.WaitGroup{}
80 wg.Add(10)
81 for i := 0; i < 10; i++ {
82 go func(start, end int) {
83 for i := start; i < end; i++ {
84 lock.Lock()
85 q.PushFront(i)
86 lock.Unlock()
87 }
88 for i := start; i < end; i++ {
89 lock.Lock()
90 q.Front()
91 lock.Unlock()
92 }
93 wg.Done()
94 }(i*10000, (i+1)*10000)
95 }
96 wg.Wait()
97 }
98}

Callers

nothing calls this directly

Calls 2

LockMethod · 0.65
UnlockMethod · 0.65

Tested by

no test coverage detected