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

Function BenchmarkParallelByCategory

parser/parser_test.go:2573–2592  ·  view source on GitHub ↗

BenchmarkParallelByCategory benchmarks parsing concurrently across goroutines by category.

(b *testing.B)

Source from the content-addressed store, hash-verified

2571
2572// BenchmarkParallelByCategory benchmarks parsing concurrently across goroutines by category.
2573func BenchmarkParallelByCategory(b *testing.B) {
2574 p := newBenchmarkCategoryParser(b)
2575 for _, cat := range benchCategories {
2576 b.Run(cat.name, func(b *testing.B) {
2577 b.ResetTimer()
2578 b.RunParallel(func(pb *testing.PB) {
2579 for pb.Next() {
2580 for _, tc := range cat.cases {
2581 src := common.NewTextSource(tc.I)
2582 _, errs := p.Parse(src)
2583 hasErr := len(errs.GetErrors()) > 0
2584 if hasErr != tc.E {
2585 b.Fatalf("p.Parse(%q) got error: %v, expected error: %v", tc.I, hasErr, tc.E)
2586 }
2587 }
2588 }
2589 })
2590 })
2591 }
2592}
2593
2594// optMapMacro expands `m.optMap(v, f)` into a conditional comprehension.
2595var optMapMacro = NewReceiverMacro("optMap", 2, optMapExpander)

Callers

nothing calls this directly

Calls 5

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

Tested by

no test coverage detected