| 173 | } |
| 174 | } |
| 175 | func BenchmarkLogLineToTextFromParse(b *testing.B) { |
| 176 | fields := make([][]byte, 0, baker.LogLineNumFields) |
| 177 | for i := 0; i < int(baker.LogLineNumFields); i++ { |
| 178 | fields = append(fields, []byte("xxxxxxxxxx")) |
| 179 | } |
| 180 | |
| 181 | nparse := []int{1, 50, 500, 1000, 2000, 3000} |
| 182 | for _, nparse := range nparse { |
| 183 | b.Run(fmt.Sprintf("parse=%d", nparse), func(b *testing.B) { |
| 184 | text := bytes.Join(fields[:nparse], []byte(",")) |
| 185 | |
| 186 | ll := baker.LogLine{FieldSeparator: ','} |
| 187 | ll.Parse(text, nil) |
| 188 | |
| 189 | b.ReportAllocs() |
| 190 | b.ResetTimer() |
| 191 | for n := 0; n < b.N; n++ { |
| 192 | _ = ll.ToText(nil) |
| 193 | } |
| 194 | }) |
| 195 | } |
| 196 | } |
| 197 | func BenchmarkLogLineToTextFromParseSet(b *testing.B) { |
| 198 | fields := make([][]byte, 0, baker.LogLineNumFields) |
| 199 | for i := 0; i < int(baker.LogLineNumFields); i++ { |