(b *testing.B, exp time.Duration)
| 1495 | } |
| 1496 | |
| 1497 | func benchmarkCacheGetConcurrent(b *testing.B, exp time.Duration) { |
| 1498 | b.StopTimer() |
| 1499 | tc := New(exp, 0) |
| 1500 | tc.Set("foo", "bar", DefaultExpiration) |
| 1501 | wg := new(sync.WaitGroup) |
| 1502 | workers := runtime.NumCPU() |
| 1503 | each := b.N / workers |
| 1504 | wg.Add(workers) |
| 1505 | b.StartTimer() |
| 1506 | for i := 0; i < workers; i++ { |
| 1507 | go func() { |
| 1508 | for j := 0; j < each; j++ { |
| 1509 | tc.Get("foo") |
| 1510 | } |
| 1511 | wg.Done() |
| 1512 | }() |
| 1513 | } |
| 1514 | wg.Wait() |
| 1515 | } |
| 1516 | |
| 1517 | func BenchmarkRWMutexMapGetConcurrent(b *testing.B) { |
| 1518 | b.StopTimer() |
no test coverage detected
searching dependent graphs…