Skip to content

Commit

Permalink
tidb: add insert benchmark.
Browse files Browse the repository at this point in the history
  • Loading branch information
coocood committed Apr 3, 2016
1 parent dbcd736 commit 89650ca
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions bench_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -170,3 +170,25 @@ func BenchmarkDecimalIndexLookup(b *testing.B) {
readResult(rs[0], 1)
}
}

func BenchmarkInsertWithIndex(b *testing.B) {
b.StopTimer()
se := prepareBenchSession()
mustExecute(se, "drop table if exists t")
mustExecute(se, "create table t (pk int primary key, col int, index idx (col))")
b.StartTimer()
for i := 0; i < b.N; i++ {
mustExecute(se, fmt.Sprintf("insert t values (%d, %d)", i, i))
}
}

func BenchmarkInsertNoIndex(b *testing.B) {
b.StopTimer()
se := prepareBenchSession()
mustExecute(se, "drop table if exists t")
mustExecute(se, "create table t (pk int primary key, col int)")
b.StartTimer()
for i := 0; i < b.N; i++ {
mustExecute(se, fmt.Sprintf("insert t values (%d, %d)", i, i))
}
}

0 comments on commit 89650ca

Please sign in to comment.