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

Function BenchmarkParallelByCategory

parser/parser_test.go:3829–3857  ·  view source on GitHub ↗

BenchmarkParallelByCategory benchmarks parsing concurrently across goroutines by category.

(b *testing.B)

Source from the content-addressed store, hash-verified

3827
3828// BenchmarkParallelByCategory benchmarks parsing concurrently across goroutines by category.
3829func BenchmarkParallelByCategory(b *testing.B) {
3830 for _, pratt := range []bool{false, true} {
3831 mode := "antlr"
3832 if pratt {
3833 mode = "pratt"
3834 }
3835 b.Run(mode, func(b *testing.B) {
3836 p := newBenchmarkCategoryParser(b, EnablePrattParser(pratt))
3837 for _, cat := range benchCategories {
3838 b.Run(cat.name, func(b *testing.B) {
3839 b.ReportAllocs()
3840 b.ResetTimer()
3841 b.RunParallel(func(pb *testing.PB) {
3842 for pb.Next() {
3843 for _, tc := range cat.cases {
3844 src := common.NewTextSource(tc.I)
3845 _, errs := p.Parse(src)
3846 hasErr := len(errs.GetErrors()) > 0
3847 if hasErr != tc.E {
3848 b.Fatalf("p.Parse(%q) got error: %v, expected error: %v", tc.I, hasErr, tc.E)
3849 }
3850 }
3851 }
3852 })
3853 })
3854 }
3855 })
3856 }
3857}
3858
3859// optMapMacro expands `m.optMap(v, f)` into a conditional comprehension.
3860var optMapMacro = NewReceiverMacro("optMap", 2, optMapExpander)

Callers

nothing calls this directly

Calls 6

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

Tested by

no test coverage detected