Esempio n. 1
0
func BenchmarkSuite(b *testing.B) {
	if !testsuite.BenchSuiteExists() {
		b.Skip("benchsuite not available")
	}
	benches, err := testsuite.ReadBenchmarkSuite()
	if err != nil {
		b.Fatal(err)
	}
	for _, benchCase := range benches {
		b.Run(benchCase.Name, func(b *testing.B) {
			bench(b, benchCase.Grammar, benchCase.Parsers, benchCase.Record)
		})
	}
}
Esempio n. 2
0
func BenchmarkSuite(b *testing.B) {
	if !testsuite.BenchSuiteExists() {
		b.Skip("benchsuite not available")
	}
	benches, err := testsuite.ReadBenchmarkSuite()
	if err != nil {
		b.Fatal(err)
	}
	for _, benchCase := range benches {
		b.Run(benchCase.Name, func(b *testing.B) {
			num := len(benchCase.Parsers)
			b.ResetTimer()
			for i := 0; i < b.N; i++ {
				if err := benchCase.Parsers[i%num].Reset(); err != nil {
					b.Fatal(err)
				}
				if _, err := interp.Interpret(benchCase.Grammar, benchCase.Parsers[i%num]); err != nil {
					b.Fatal(err)
				}
			}
		})
	}
}