File: bigcache_timing_test.go

package info (click to toggle)
golang-github-victoriametrics-fastcache 1.12.0%2Bds1-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 192 kB
  • sloc: makefile: 2
file content (33 lines) | stat: -rw-r--r-- 612 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
package fastcache

import (
	"testing"
)

func BenchmarkSetBig(b *testing.B) {
	key := []byte("key12345")
	value := createValue(256*1024, 0)
	c := New(1024 * 1024)
	b.SetBytes(int64(len(value)))
	b.ReportAllocs()
	b.RunParallel(func(pb *testing.PB) {
		for pb.Next() {
			c.SetBig(key, value)
		}
	})
}

func BenchmarkGetBig(b *testing.B) {
	key := []byte("key12345")
	value := createValue(265*1024, 0)
	c := New(1024 * 1024)
	c.SetBig(key, value)
	b.SetBytes(int64(len(value)))
	b.ReportAllocs()
	b.RunParallel(func(pb *testing.PB) {
		var buf []byte
		for pb.Next() {
			buf = c.GetBig(buf[:0], key)
		}
	})
}