Skip to content

Commit

Permalink
tidb: fix benchmark go test -test.bench=. -test.run=^XXX (pingcap#5791)
Browse files Browse the repository at this point in the history
  • Loading branch information
tiancaiamao authored Feb 5, 2018
1 parent a04b2f9 commit 5373be2
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions bench_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down Expand Up @@ -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 {
Expand Down

0 comments on commit 5373be2

Please sign in to comment.