MCPcopy Create free account
hub / github.com/baidu/EasyFaaS / benchmarkCacheGetConcurrent

Function benchmarkCacheGetConcurrent

pkg/util/cache/cache_test.go:1513–1531  ·  view source on GitHub ↗
(b *testing.B, exp time.Duration)

Source from the content-addressed store, hash-verified

1511}
1512
1513func benchmarkCacheGetConcurrent(b *testing.B, exp time.Duration) {
1514 b.StopTimer()
1515 tc := New(exp, 0)
1516 tc.Set("foo", "bar", DefaultExpiration)
1517 wg := new(sync.WaitGroup)
1518 workers := runtime.NumCPU()
1519 each := b.N / workers
1520 wg.Add(workers)
1521 b.StartTimer()
1522 for i := 0; i < workers; i++ {
1523 go func() {
1524 for j := 0; j < each; j++ {
1525 tc.Get("foo")
1526 }
1527 wg.Done()
1528 }()
1529 }
1530 wg.Wait()
1531}
1532
1533func BenchmarkRWMutexMapGetConcurrent(b *testing.B) {
1534 b.StopTimer()

Calls 6

DoneMethod · 0.80
NewFunction · 0.70
SetMethod · 0.65
GetMethod · 0.65
WaitMethod · 0.65
AddMethod · 0.45

Tested by

no test coverage detected