Skip to content

Commit 02fdc09

Browse files
committed
[cache] improve benchmark isolation
1 parent 212ffce commit 02fdc09

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

pkg/cache/memory_bench_test.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,12 @@ func BenchmarkMemoryCache_Set(b *testing.B) {
1717
cache := cache.NewMemory(0)
1818
ctx := context.Background()
1919
key := "benchmark-key"
20-
value := "benchmark-value"
20+
value := []byte("benchmark-value")
2121

2222
b.ResetTimer()
2323
b.RunParallel(func(pb *testing.PB) {
2424
for pb.Next() {
25-
cache.Set(ctx, key, []byte(value))
25+
cache.Set(ctx, key, value)
2626
}
2727
})
2828
}
@@ -310,7 +310,7 @@ func BenchmarkMemoryCache_TTLOverhead(b *testing.B) {
310310
c := cache.NewMemory(0)
311311
ctx := context.Background()
312312
key := "benchmark-key"
313-
value := "benchmark-value"
313+
value := []byte("benchmark-value")
314314
ttl := time.Hour
315315

316316
benchmarks := []struct {
@@ -327,9 +327,9 @@ func BenchmarkMemoryCache_TTLOverhead(b *testing.B) {
327327
b.RunParallel(func(pb *testing.PB) {
328328
for pb.Next() {
329329
if bm.withTTL {
330-
c.Set(ctx, key, []byte(value), cache.WithTTL(ttl))
330+
c.Set(ctx, key, value, cache.WithTTL(ttl))
331331
} else {
332-
c.Set(ctx, key, []byte(value))
332+
c.Set(ctx, key, value)
333333
}
334334
}
335335
})

0 commit comments

Comments
 (0)