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