(b *testing.B)
| 195 | } |
| 196 | } |
| 197 | func 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 | |
| 227 | func BenchmarkLogLineCopy(b *testing.B) { |
| 228 | b.Run("set=0", func(b *testing.B) { |
nothing calls this directly
no test coverage detected