From 89650ca55606ece6f3ab9d11c30d1db9746d45f5 Mon Sep 17 00:00:00 2001 From: Ewan Chou Date: Sun, 3 Apr 2016 13:09:27 +0800 Subject: [PATCH] tidb: add insert benchmark. --- bench_test.go | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/bench_test.go b/bench_test.go index 690908dd98..eb40debc26 100644 --- a/bench_test.go +++ b/bench_test.go @@ -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)) + } +}