Skip to content

Commit

Permalink
test: speed up TestVectorizedMergeJoin by removing some test cases (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
qw4990 authored and sre-bot committed Jan 19, 2020
1 parent 34bb3e5 commit 5017579
Showing 1 changed file with 11 additions and 24 deletions.
35 changes: 11 additions & 24 deletions executor/merge_join_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ package executor_test
import (
"bytes"
"fmt"
"github.com/pingcap/tidb/sessionctx/variable"
"math/rand"
"strings"

Expand Down Expand Up @@ -461,12 +462,13 @@ func (s *testSuite2) TestMergeJoinDifferentTypes(c *C) {
func (s *testSuite2) TestVectorizedMergeJoin(c *C) {
tk := testkit.NewTestKit(c, s.store)
tk.MustExec("use test")
tk.MustExec("drop table if exists t1")
tk.MustExec("drop table if exists t2")
tk.MustExec("create table t1 (a int, b int)")
tk.MustExec("create table t2 (a int, b int)")
runTest := func(t1, t2 []int) {
tk.MustExec("create table t1 (a int, b int)")
defer tk.MustExec("drop table t1")
tk.MustExec("create table t2 (a int, b int)")
defer tk.MustExec("drop table t2")

tk.MustExec("truncate table t1")
tk.MustExec("truncate table t2")
insert := func(tName string, ts []int) {
for i, n := range ts {
if n == 0 {
Expand Down Expand Up @@ -522,7 +524,7 @@ func (s *testSuite2) TestVectorizedMergeJoin(c *C) {
}
}

tk.Se.GetSessionVars().MaxChunkSize = 16
tk.Se.GetSessionVars().MaxChunkSize = variable.DefInitChunkSize
chunkSize := tk.Se.GetSessionVars().MaxChunkSize
cases := []struct {
t1 []int
Expand All @@ -543,27 +545,12 @@ func (s *testSuite2) TestVectorizedMergeJoin(c *C) {
{[]int{chunkSize + 1}, []int{chunkSize}},
{[]int{chunkSize + 1}, []int{chunkSize - 1}},
{[]int{chunkSize + 1}, []int{chunkSize + 1}},
{[]int{1, 1, 1}, []int{chunkSize + 1, chunkSize*5 + 10, chunkSize - 10}},
{[]int{0, 0, chunkSize}, []int{chunkSize + 1, chunkSize*5 + 10, chunkSize - 10}},
{[]int{chunkSize + 1, 0, chunkSize}, []int{chunkSize + 1, chunkSize*5 + 10, chunkSize - 10}},
{[]int{1, 1, 1}, []int{chunkSize + 1, chunkSize*5 + 5, chunkSize - 5}},
{[]int{0, 0, chunkSize}, []int{chunkSize + 1, chunkSize*5 + 5, chunkSize - 5}},
{[]int{chunkSize + 1, 0, chunkSize}, []int{chunkSize + 1, chunkSize*5 + 5, chunkSize - 5}},
}
for _, ca := range cases {
runTest(ca.t1, ca.t2)
runTest(ca.t2, ca.t1)
}

// random complex cases
genCase := func() []int {
n := rand.Intn(32) + 32
ts := make([]int, n)
for i := 0; i < n; i++ {
ts[i] = rand.Intn(chunkSize * 2)
}
return ts
}
for i := 0; i < 16; i++ {
t1 := genCase()
t2 := genCase()
runTest(t1, t2)
}
}

0 comments on commit 5017579

Please sign in to comment.