MCPcopy Create free account
hub / github.com/cel-expr/cel-go / BenchmarkByCategory

Function BenchmarkByCategory

parser/parser_test.go:3800–3826  ·  view source on GitHub ↗

BenchmarkByCategory benchmarks parsing organized by workload categories.

(b *testing.B)

Source from the content-addressed store, hash-verified

3798
3799// BenchmarkByCategory benchmarks parsing organized by workload categories.
3800func BenchmarkByCategory(b *testing.B) {
3801 for _, pratt := range []bool{false, true} {
3802 mode := "antlr"
3803 if pratt {
3804 mode = "pratt"
3805 }
3806 b.Run(mode, func(b *testing.B) {
3807 p := newBenchmarkCategoryParser(b, EnablePrattParser(pratt))
3808 for _, cat := range benchCategories {
3809 b.Run(cat.name, func(b *testing.B) {
3810 b.ReportAllocs()
3811 b.ResetTimer()
3812 for i := 0; i < b.N; i++ {
3813 for _, tc := range cat.cases {
3814 src := common.NewTextSource(tc.I)
3815 _, errs := p.Parse(src)
3816 hasErr := len(errs.GetErrors()) > 0
3817 if hasErr != tc.E {
3818 b.Fatalf("p.Parse(%q) got error: %v, expected error: %v", tc.I, hasErr, tc.E)
3819 }
3820 }
3821 }
3822 })
3823 }
3824 })
3825 }
3826}
3827
3828// BenchmarkParallelByCategory benchmarks parsing concurrently across goroutines by category.
3829func BenchmarkParallelByCategory(b *testing.B) {

Callers

nothing calls this directly

Calls 5

NewTextSourceFunction · 0.92
EnablePrattParserFunction · 0.85
GetErrorsMethod · 0.80
ParseMethod · 0.65

Tested by

no test coverage detected