Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
Signed-off-by: Weizhen Wang <wangweizhen@pingcap.com>
  • Loading branch information
hawkingrei committed Jul 12, 2023
1 parent e1a5496 commit 4764294
Show file tree
Hide file tree
Showing 2 changed files with 54 additions and 0 deletions.
27 changes: 27 additions & 0 deletions statistics/handle/cache/internal/lru/bench_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,3 +43,30 @@ func BenchmarkLruPut(b *testing.B) {

b.StopTimer()
}

func BenchmarkLruPutGet(b *testing.B) {
var (
wg sync.WaitGroup
c = NewStatsLruCache(defaultSize)
)
b.ResetTimer()

for i := 0; i < b.N; i++ {
wg.Add(1)
go func(i int) {
defer wg.Done()
t1 := testutil.NewMockStatisticsTable(1, 1, true, false, false)
c.Put(int64(i), t1)
}(i)
}
for i := 0; i < b.N; i++ {
wg.Add(1)
go func(i int) {
defer wg.Done()
c.Get(int64(i))
}(i)
}
wg.Wait()

b.StopTimer()
}
27 changes: 27 additions & 0 deletions statistics/handle/cache/internal/mapcache/bench_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,3 +41,30 @@ func BenchmarkMapCachePut(b *testing.B) {
wg.Wait()
b.StopTimer()
}

func BenchmarkMapCachePutGet(b *testing.B) {
var (
wg sync.WaitGroup
c = NewMapCache()
)
b.ResetTimer()

for i := 0; i < b.N; i++ {
wg.Add(1)
go func(i int) {
defer wg.Done()
t1 := testutil.NewMockStatisticsTable(1, 1, true, false, false)
c.Put(int64(i), t1)
}(i)
}
for i := 0; i < b.N; i++ {
wg.Add(1)
go func(i int) {
defer wg.Done()
c.Get(int64(i))
}(i)
}
wg.Wait()

b.StopTimer()
}

0 comments on commit 4764294

Please sign in to comment.