Skip to content

Commit

Permalink
change planner benchmark to only read the input file once
Browse files Browse the repository at this point in the history
Signed-off-by: Andres Taylor <[email protected]>
  • Loading branch information
systay committed Dec 29, 2020
1 parent cf1ad11 commit 000426e
Showing 1 changed file with 14 additions and 10 deletions.
24 changes: 14 additions & 10 deletions go/vt/vtgate/planbuilder/plan_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -584,24 +584,28 @@ func BenchmarkPlanner(b *testing.B) {
sysVarEnabled: true,
}
for _, filename := range filenames {
b.Run(filename+"v3", func(b *testing.B) {
benchmarkPlanner(b, V3, filename, vschema)
var testCases []testCase
for tc := range iterateExecFile(filename) {
testCases = append(testCases, tc)
}
b.Run(filename+"-v3", func(b *testing.B) {
benchmarkPlanner(b, V3, testCases, vschema)
})
b.Run(filename+"v4", func(b *testing.B) {
benchmarkPlanner(b, V4, filename, vschema)
b.Run(filename+"-v4", func(b *testing.B) {
benchmarkPlanner(b, V4, testCases, vschema)
})
b.Run(filename+"v4greedy", func(b *testing.B) {
benchmarkPlanner(b, V4GreedyOnly, filename, vschema)
b.Run(filename+"-v4greedy", func(b *testing.B) {
benchmarkPlanner(b, V4GreedyOnly, testCases, vschema)
})
b.Run(filename+"v4left2right", func(b *testing.B) {
benchmarkPlanner(b, V4Left2Right, filename, vschema)
b.Run(filename+"-v4left2right", func(b *testing.B) {
benchmarkPlanner(b, V4Left2Right, testCases, vschema)
})
}
}

func benchmarkPlanner(b *testing.B, version PlannerVersion, filename string, vschema *vschemaWrapper) {
func benchmarkPlanner(b *testing.B, version PlannerVersion, testCases []testCase, vschema *vschemaWrapper) {
for n := 0; n < b.N; n++ {
for tcase := range iterateExecFile(filename) {
for _, tcase := range testCases {
if tcase.output2ndPlanner != "" {
vschema.version = version
_, _ = TestBuilder(tcase.input, vschema)
Expand Down

0 comments on commit 000426e

Please sign in to comment.