(b *testing.B)
| 1515 | } |
| 1516 | |
| 1517 | func BenchmarkRWMutexMapGetConcurrent(b *testing.B) { |
| 1518 | b.StopTimer() |
| 1519 | m := map[string]string{ |
| 1520 | "foo": "bar", |
| 1521 | } |
| 1522 | mu := sync.RWMutex{} |
| 1523 | wg := new(sync.WaitGroup) |
| 1524 | workers := runtime.NumCPU() |
| 1525 | each := b.N / workers |
| 1526 | wg.Add(workers) |
| 1527 | b.StartTimer() |
| 1528 | for i := 0; i < workers; i++ { |
| 1529 | go func() { |
| 1530 | for j := 0; j < each; j++ { |
| 1531 | mu.RLock() |
| 1532 | _, _ = m["foo"] |
| 1533 | mu.RUnlock() |
| 1534 | } |
| 1535 | wg.Done() |
| 1536 | }() |
| 1537 | } |
| 1538 | wg.Wait() |
| 1539 | } |
| 1540 | |
| 1541 | func BenchmarkCacheGetManyConcurrentExpiring(b *testing.B) { |
| 1542 | benchmarkCacheGetManyConcurrent(b, 5*time.Minute) |
nothing calls this directly
no test coverage detected
searching dependent graphs…