BenchmarkParallelByCategory benchmarks parsing concurrently across goroutines by category.
(b *testing.B)
| 3827 | |
| 3828 | // BenchmarkParallelByCategory benchmarks parsing concurrently across goroutines by category. |
| 3829 | func 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. |
| 3860 | var optMapMacro = NewReceiverMacro("optMap", 2, optMapExpander) |
nothing calls this directly
no test coverage detected