MCPcopy
hub / github.com/kopia/kopia / TestConcurrentCountMap_ConcurrentIncrement

Function TestConcurrentCountMap_ConcurrentIncrement

internal/stats/count_map_test.go:126–155  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

124}
125
126func TestConcurrentCountMap_ConcurrentIncrement(t *testing.T) {
127 const (
128 key = 7
129 concurrency = 8
130 inc = 1000
131 )
132
133 var m CountersMap[int]
134
135 var wg sync.WaitGroup
136
137 wg.Add(concurrency)
138
139 for range concurrency {
140 go func() {
141 for range inc {
142 m.Increment(key)
143 }
144
145 wg.Done()
146 }()
147 }
148
149 wg.Wait()
150
151 got, found := m.Get(key)
152
153 require.True(t, found)
154 require.EqualValues(t, concurrency*inc, got)
155}

Callers

nothing calls this directly

Calls 5

IncrementMethod · 0.80
DoneMethod · 0.65
WaitMethod · 0.65
GetMethod · 0.65
AddMethod · 0.45

Tested by

no test coverage detected