tidb: fix benchmark go test -test.bench=. -test.run=^XXX (#5791)
This commit is contained in:
@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user