tidb: fix benchmark go test -test.bench=. -test.run=^XXX (#5791)

This commit is contained in:
tiancaiamao
2018-02-05 06:25:12 -06:00
committed by GitHub
parent a04b2f9a8d
commit 5373be2ae7

View File

@ -62,6 +62,10 @@ func prepareSortBenchData(se Session, colType string, valueFormat string, valueC
mustExecute(se, "begin")
r := rand.New(rand.NewSource(time.Now().UnixNano()))
for i := 0; i < valueCount; i++ {
if i%1000 == 0 {
mustExecute(se, "commit")
mustExecute(se, "begin")
}
mustExecute(se, "insert t (col) values ("+fmt.Sprintf(valueFormat, r.Intn(valueCount))+")")
}
mustExecute(se, "commit")
@ -93,7 +97,9 @@ func readResult(goCtx goctx.Context, rs ast.RecordSet, count int) {
func BenchmarkBasic(b *testing.B) {
goCtx := goctx.Background()
b.StopTimer()
se := prepareBenchSession()
b.StartTimer()
for i := 0; i < b.N; i++ {
rs, err := se.Execute(goCtx, "select 1")
if err != nil {