MCPcopy Create free account
hub / github.com/AdRoll/baker / BenchmarkLogLineToTextFromParseSet

Function BenchmarkLogLineToTextFromParseSet

bench_test.go:197–225  ·  view source on GitHub ↗
(b *testing.B)

Source from the content-addressed store, hash-verified

195 }
196}
197func BenchmarkLogLineToTextFromParseSet(b *testing.B) {
198 fields := make([][]byte, 0, baker.LogLineNumFields)
199 for i := 0; i < int(baker.LogLineNumFields); i++ {
200 fields = append(fields, []byte("xxxxxxxxxx"))
201 }
202
203 nparse := []int{100, 1000, 3000}
204 nset := []int{5, 50, 100, 254}
205 for _, nparse := range nparse {
206 for _, nset := range nset {
207 b.Run(fmt.Sprintf("parse=%d,set=%d", nparse, nset), func(b *testing.B) {
208 text := bytes.Join(fields[:nparse], []byte(","))
209
210 ll := baker.LogLine{FieldSeparator: ','}
211 ll.Parse(text, nil)
212
213 for i := 0; i < nset; i++ {
214 ll.Set(baker.FieldIndex(i), []byte("newvalue"))
215 }
216
217 b.ReportAllocs()
218 b.ResetTimer()
219 for n := 0; n < b.N; n++ {
220 _ = ll.ToText(nil)
221 }
222 })
223 }
224 }
225}
226
227func BenchmarkLogLineCopy(b *testing.B) {
228 b.Run("set=0", func(b *testing.B) {

Callers

nothing calls this directly

Calls 5

ParseMethod · 0.95
SetMethod · 0.95
ToTextMethod · 0.95
FieldIndexTypeAlias · 0.92
RunMethod · 0.65

Tested by

no test coverage detected