MCPcopy
hub / github.com/grafana/tempo / BenchmarkIntern

Function BenchmarkIntern

pkg/parquetquery/intern/intern_test.go:112–155  ·  view source on GitHub ↗
(b *testing.B)

Source from the content-addressed store, hash-verified

110}
111
112func BenchmarkIntern(b *testing.B) {
113 words := []string{"foo", "bar", "baz", "qux", "quux", "corge", "grault", "garply", "waldo", "fred", "plugh", "xyzzy", "thud"}
114 testCases := []struct {
115 name string
116 valueFn func(i int) pq.Value
117 }{
118 {
119 name: "byte_array",
120 valueFn: func(i int) pq.Value { return pq.ByteArrayValue([]byte(words[i%len(words)])) },
121 },
122 {
123 name: "fixed_len_byte_array",
124 valueFn: func(i int) pq.Value { return pq.FixedLenByteArrayValue([]byte(words[i%len(words)])) },
125 },
126 {
127 name: "bool",
128 valueFn: func(i int) pq.Value { return pq.BooleanValue(i%2 == 0) },
129 },
130 {
131 name: "int32",
132 valueFn: func(i int) pq.Value { return pq.Int32Value(int32(i)) },
133 },
134 }
135
136 for _, tc := range testCases {
137 b.Run(fmt.Sprintf("no_interning: %s", tc.name), func(b *testing.B) {
138 for i := 0; i < b.N; i++ {
139 value := tc.valueFn(i)
140 _ = value.Clone()
141 }
142 })
143
144 b.Run(fmt.Sprintf("interning: %s", tc.name), func(b *testing.B) {
145 interner := New()
146 defer interner.Close()
147
148 b.ResetTimer()
149 for i := 0; i < b.N; i++ {
150 value := tc.valueFn(i)
151 _ = interner.UnsafeClone(&value)
152 }
153 })
154 }
155}

Callers

nothing calls this directly

Calls 5

CloneMethod · 0.80
UnsafeCloneMethod · 0.80
NewFunction · 0.70
CloseMethod · 0.65
RunMethod · 0.45

Tested by

no test coverage detected