Skip to content

Commit

Permalink
executor: accelerate TestMemCount (#19581)
Browse files Browse the repository at this point in the history
* test

* executor: accelerate TestMemCount

* refine

* fix ci

Co-authored-by: ti-srebot <66930949+ti-srebot@users.noreply.github.com>
  • Loading branch information
XuHuaiyu and ti-srebot committed Aug 29, 2020
1 parent 6cba270 commit f3c8b00
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 22 deletions.
4 changes: 2 additions & 2 deletions executor/aggfuncs/aggfunc_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -241,8 +241,8 @@ type aggMemTest struct {
isDistinct bool
}

func buildAggMemTester(funcName string, tp byte, numRows int, allocMemDelta int64, updateMemDeltaGens updateMemDeltaGens, isDistinct bool, results ...interface{}) aggMemTest {
aggTest := buildAggTester(funcName, tp, numRows, results)
func buildAggMemTester(funcName string, tp byte, numRows int, allocMemDelta int64, updateMemDeltaGens updateMemDeltaGens, isDistinct bool) aggMemTest {
aggTest := buildAggTester(funcName, tp, numRows)
pt := aggMemTest{
aggTest: aggTest,
allocMemDelta: allocMemDelta,
Expand Down
8 changes: 4 additions & 4 deletions executor/aggfuncs/func_avg_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,13 +45,13 @@ func (s *testSuite) TestAvg(c *C) {
func (s *testSuite) TestMemAvg(c *C) {
tests := []aggMemTest{
buildAggMemTester(ast.AggFuncAvg, mysql.TypeNewDecimal, 5,
aggfuncs.DefPartialResult4AvgDecimalSize, defaultUpdateMemDeltaGens, false, nil, 2.0),
aggfuncs.DefPartialResult4AvgDecimalSize, defaultUpdateMemDeltaGens, false),
buildAggMemTester(ast.AggFuncAvg, mysql.TypeNewDecimal, 5,
aggfuncs.DefPartialResult4AvgDistinctDecimalSize, distinctUpdateMemDeltaGens, true, nil, 2.0),
aggfuncs.DefPartialResult4AvgDistinctDecimalSize, distinctUpdateMemDeltaGens, true),
buildAggMemTester(ast.AggFuncAvg, mysql.TypeDouble, 5,
aggfuncs.DefPartialResult4AvgFloat64Size, defaultUpdateMemDeltaGens, false, nil, 2.0),
aggfuncs.DefPartialResult4AvgFloat64Size, defaultUpdateMemDeltaGens, false),
buildAggMemTester(ast.AggFuncAvg, mysql.TypeDouble, 5,
aggfuncs.DefPartialResult4AvgDistinctFloat64Size, distinctUpdateMemDeltaGens, true, nil, 2.0),
aggfuncs.DefPartialResult4AvgDistinctFloat64Size, distinctUpdateMemDeltaGens, true),
}
for _, test := range tests {
s.testAggMemFunc(c, test)
Expand Down
28 changes: 12 additions & 16 deletions executor/aggfuncs/func_count_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ import (
"github.com/pingcap/parser/ast"
"github.com/pingcap/parser/mysql"
"github.com/pingcap/tidb/executor/aggfuncs"
"github.com/pingcap/tidb/util/israce"
)

func genApproxDistinctMergePartialResult(begin, end uint64) string {
Expand Down Expand Up @@ -103,30 +102,27 @@ func (s *testSuite) TestCount(c *C) {
}

func (s *testSuite) TestMemCount(c *C) {
if israce.RaceEnabled {
c.Skip("skip race test")
}
tests := []aggMemTest{
buildAggMemTester(ast.AggFuncCount, mysql.TypeLonglong, 5,
aggfuncs.DefPartialResult4CountDistinctIntSize, distinctUpdateMemDeltaGens, true, 0, 5),
aggfuncs.DefPartialResult4CountDistinctIntSize, distinctUpdateMemDeltaGens, true),
buildAggMemTester(ast.AggFuncCount, mysql.TypeFloat, 5,
aggfuncs.DefPartialResult4CountDistinctRealSize, distinctUpdateMemDeltaGens, true, 0, 5),
aggfuncs.DefPartialResult4CountDistinctRealSize, distinctUpdateMemDeltaGens, true),
buildAggMemTester(ast.AggFuncCount, mysql.TypeDouble, 5,
aggfuncs.DefPartialResult4CountDistinctRealSize, distinctUpdateMemDeltaGens, true, 0, 5),
aggfuncs.DefPartialResult4CountDistinctRealSize, distinctUpdateMemDeltaGens, true),
buildAggMemTester(ast.AggFuncCount, mysql.TypeNewDecimal, 5,
aggfuncs.DefPartialResult4CountDistinctDecimalSize, distinctUpdateMemDeltaGens, true, 0, 5),
aggfuncs.DefPartialResult4CountDistinctDecimalSize, distinctUpdateMemDeltaGens, true),
buildAggMemTester(ast.AggFuncCount, mysql.TypeString, 5,
aggfuncs.DefPartialResult4CountDistinctStringSize, distinctUpdateMemDeltaGens, true, 0, 5),
aggfuncs.DefPartialResult4CountDistinctStringSize, distinctUpdateMemDeltaGens, true),
buildAggMemTester(ast.AggFuncCount, mysql.TypeDate, 5,
aggfuncs.DefPartialResult4CountWithDistinctSize, distinctUpdateMemDeltaGens, true, 0, 5),
aggfuncs.DefPartialResult4CountWithDistinctSize, distinctUpdateMemDeltaGens, true),
buildAggMemTester(ast.AggFuncCount, mysql.TypeDuration, 5,
aggfuncs.DefPartialResult4CountDistinctDurationSize, distinctUpdateMemDeltaGens, true, 0, 5),
aggfuncs.DefPartialResult4CountDistinctDurationSize, distinctUpdateMemDeltaGens, true),
buildAggMemTester(ast.AggFuncCount, mysql.TypeJSON, 5,
aggfuncs.DefPartialResult4CountWithDistinctSize, distinctUpdateMemDeltaGens, true, 0, 5),
buildAggMemTester(ast.AggFuncApproxCountDistinct, mysql.TypeLonglong, 100000,
aggfuncs.DefPartialResult4ApproxCountDistinctSize, approxCountDistinctUpdateMemDeltaGens, true, 0, 100000),
buildAggMemTester(ast.AggFuncApproxCountDistinct, mysql.TypeString, 100000,
aggfuncs.DefPartialResult4ApproxCountDistinctSize, approxCountDistinctUpdateMemDeltaGens, true, 0, 100000),
aggfuncs.DefPartialResult4CountWithDistinctSize, distinctUpdateMemDeltaGens, true),
buildAggMemTester(ast.AggFuncApproxCountDistinct, mysql.TypeLonglong, 5,
aggfuncs.DefPartialResult4ApproxCountDistinctSize, approxCountDistinctUpdateMemDeltaGens, true),
buildAggMemTester(ast.AggFuncApproxCountDistinct, mysql.TypeString, 5,
aggfuncs.DefPartialResult4ApproxCountDistinctSize, approxCountDistinctUpdateMemDeltaGens, true),
}
for _, test := range tests {
s.testAggMemFunc(c, test)
Expand Down

0 comments on commit f3c8b00

Please sign in to comment.