Skip to content

Commit

Permalink
feat(freecache):
Browse files Browse the repository at this point in the history
补充bench test
  • Loading branch information
彭业昌 committed Feb 15, 2023
1 parent 1311c5c commit a054396
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
1 change: 1 addition & 0 deletions pkg/cache/xfreecache/v2/cache.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package xfreecache

import (
"fmt"

"github.com/douyu/jupiter/pkg/xlog"
"github.com/samber/lo"
"go.uber.org/zap"
Expand Down
9 changes: 8 additions & 1 deletion pkg/cache/xfreecache/v2/encode_bench_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ func BenchmarkDecodeProto(b *testing.B) {
func BenchmarkEncodeProto(b *testing.B) {
b.ReportAllocs()
for i := 0; i < b.N; i++ {
_, _ = marshal[*helloworldv1.SayHiResponse](helloReply)
_, _ = proto.Marshal(helloReply)
}
}

Expand All @@ -76,3 +76,10 @@ func BenchmarkDecodeProtoWithReflect(b *testing.B) {
_, _ = unmarshal[*helloworldv1.SayHiResponse](res)
}
}

func BenchmarkEncodeProtoWithReflect(b *testing.B) {
b.ReportAllocs()
for i := 0; i < b.N; i++ {
_, _ = marshal[*helloworldv1.SayHiResponse](helloReply)
}
}

0 comments on commit a054396

Please sign in to comment.