Skip to content

Commit

Permalink
expression: support for testing a single vectorized evaluation functi…
Browse files Browse the repository at this point in the history
…on (#12153)
  • Loading branch information
Reminiscent authored and qw4990 committed Sep 18, 2019
1 parent 96716e5 commit 4a87083
Showing 1 changed file with 29 additions and 4 deletions.
33 changes: 29 additions & 4 deletions expression/bench_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ package expression
// This file contains benchmarks of our expression evaluation.

import (
"flag"
"fmt"
"math/rand"
"reflect"
Expand Down Expand Up @@ -400,7 +401,7 @@ func genVecExprBenchCase(ctx sessionctx.Context, funcName string, testCase vecEx
return expr, input, output
}

// testVectorizedEvalOneVec is used to verify that the special vectorized
// testVectorizedEvalOneVec is used to verify that the vectorized
// expression is evaluated correctly during projection
func testVectorizedEvalOneVec(c *C, vecExprCases vecExprBenchCases) {
ctx := mock.NewContext()
Expand Down Expand Up @@ -448,7 +449,7 @@ func testVectorizedEvalOneVec(c *C, vecExprCases vecExprBenchCases) {
}

// benchmarkVectorizedEvalOneVec is used to get the effect of
// using the special vectorized expression evaluations during projection
// using the vectorized expression evaluations during projection
func benchmarkVectorizedEvalOneVec(b *testing.B, vecExprCases vecExprBenchCases) {
ctx := mock.NewContext()
for funcName, testCases := range vecExprCases {
Expand Down Expand Up @@ -526,13 +527,27 @@ func genVecBuiltinFuncBenchCase(ctx sessionctx.Context, funcName string, testCas
return baseFunc, input, result
}

// testVectorizedBuiltinFunc is used to verify that the special vectorized
// testVectorizedBuiltinFunc is used to verify that the vectorized
// expression is evaluated correctly
func testVectorizedBuiltinFunc(c *C, vecExprCases vecExprBenchCases) {
testFunc := make(map[string]bool)
argList := flag.Args()
testAll := len(argList) == 0
for _, arg := range argList {
testFunc[arg] = true
}
for funcName, testCases := range vecExprCases {
for _, testCase := range testCases {
ctx := mock.NewContext()
baseFunc, input, output := genVecBuiltinFuncBenchCase(ctx, funcName, testCase)
baseFuncName := fmt.Sprintf("%v", reflect.TypeOf(baseFunc))
tmp := strings.Split(baseFuncName, ".")
baseFuncName = tmp[len(tmp)-1]

if !testAll && testFunc[baseFuncName] != true {
continue
}

it := chunk.NewIterator4Chunk(input)
i := 0
var vecWarnCnt uint16
Expand Down Expand Up @@ -651,16 +666,26 @@ func testVectorizedBuiltinFunc(c *C, vecExprCases vecExprBenchCases) {
}

// benchmarkVectorizedBuiltinFunc is used to get the effect of
// using the special vectorized expression evaluations
// using the vectorized expression evaluations
func benchmarkVectorizedBuiltinFunc(b *testing.B, vecExprCases vecExprBenchCases) {
ctx := mock.NewContext()
testFunc := make(map[string]bool)
argList := flag.Args()
testAll := len(argList) == 0
for _, arg := range argList {
testFunc[arg] = true
}
for funcName, testCases := range vecExprCases {
for _, testCase := range testCases {
baseFunc, input, output := genVecBuiltinFuncBenchCase(ctx, funcName, testCase)
baseFuncName := fmt.Sprintf("%v", reflect.TypeOf(baseFunc))
tmp := strings.Split(baseFuncName, ".")
baseFuncName = tmp[len(tmp)-1]

if !testAll && testFunc[baseFuncName] != true {
continue
}

b.Run(baseFuncName+"-VecBuiltinFunc", func(b *testing.B) {
b.ResetTimer()
switch testCase.retEvalType {
Expand Down

0 comments on commit 4a87083

Please sign in to comment.