MCPcopy
hub / github.com/nextdns/nextdns / benchRistrettoSet

Function benchRistrettoSet

resolver/ristretto_metrics_bench_test.go:71–85  ·  view source on GitHub ↗
(b *testing.B, metrics bool)

Source from the content-addressed store, hash-verified

69func BenchmarkRistretto_Set_MetricsOn(b *testing.B) { benchRistrettoSet(b, true) }
70
71func benchRistrettoSet(b *testing.B, metrics bool) {
72 c := newBenchCache(b, metrics)
73 defer c.Close()
74
75 // Value size approximates a cached DNS response payload.
76 val := make([]byte, 900)
77
78 b.ReportAllocs()
79 b.ResetTimer()
80
81 for i := 0; i < b.N; i++ {
82 // Use a changing key to avoid just updating one entry.
83 c.Set(uint64(i), val, int64(len(val)))
84 }
85}
86
87func BenchmarkRistretto_GetHit_Parallel_MetricsOff(b *testing.B) {
88 benchRistrettoGetHitParallel(b, false)

Calls 3

newBenchCacheFunction · 0.85
SetMethod · 0.65
CloseMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…