MCPcopy
hub / github.com/grafana/dskit / testConcurrency

Function testConcurrency

log/buffered_test.go:145–162  ·  view source on GitHub ↗

Copied from go-kit/log These tests are designed to be run with the race detector.

(t *testing.T, logger log.Logger, total int)

Source from the content-addressed store, hash-verified

143// These tests are designed to be run with the race detector.
144
145func testConcurrency(t *testing.T, logger log.Logger, total int) {
146 n := int(math.Sqrt(float64(total)))
147 share := total / n
148
149 var g errgroup.Group
150 for i := 0; i < n; i++ {
151 g.Go(func() error {
152 for i := 0; i < share; i++ {
153 if err := logger.Log("key", i); err != nil {
154 return err
155 }
156 }
157 return nil
158 })
159 }
160
161 require.NoError(t, g.Wait(), "concurrent logging error")
162}
163
164func benchmarkRunner(b *testing.B, logger log.Logger, f func(log.Logger)) {
165 lc := log.With(logger, "common_key", "common_value")

Callers 1

TestBufferedConcurrencyFunction · 0.85

Calls 3

GoMethod · 0.80
LogMethod · 0.45
WaitMethod · 0.45

Tested by

no test coverage detected