Skip to content

Commit

Permalink
bench: update
Browse files Browse the repository at this point in the history
Signed-off-by: ekexium <eke@fastmail.com>
  • Loading branch information
ekexium committed Jul 24, 2024
1 parent 449b84e commit 162eb46
Showing 1 changed file with 34 additions and 0 deletions.
34 changes: 34 additions & 0 deletions pkg/session/bench_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2111,3 +2111,37 @@ func BenchmarkPipelinedReplaceNoDuplicates(b *testing.B) {
b.StopTimer()
b.ReportMetric(float64(b.Elapsed().Nanoseconds()/int64(b.N*batchSize*batchNum)), "ns/row")
}

func BenchmarkPipelinedUpdate(b *testing.B) {
failpoint.Enable("tikvclient/pipelinedSkipResolveLock", "return")
defer failpoint.Disable("tikvclient/pipelinedSkipResolveLock")
logutil.InitLogger(&logutil.LogConfig{Config: log.Config{Level: "fatal"}})
se, do, st := prepareBenchSession()
defer func() {
se.Close()
do.Close()
st.Close()
}()
mustExecute(se, `create table tmp (id int, dt varchar(512))`)
mustExecute(se, `create table src (id int, dt varchar(512))`)
for i := 0; i < batchNum; i++ {
mustExecute(se, "begin")
for lines := 0; lines < batchSize; lines++ {
mustExecute(se, "insert into src values (42, repeat('x', 512))")
}
mustExecute(se, "commit")
}

se.GetSessionVars().BulkDMLEnabled = true
se.GetSessionVars().StmtCtx.InUpdateStmt = true

b.ResetTimer()
for i := 0; i < b.N; i++ {
mustExecute(se, "truncate tmp")
mustExecute(se, "insert into tmp select * from src")
b.StartTimer()
se.Execute(context.Background(), "update tmp set dt = concat(dt, 'updated')")
b.StopTimer()
}
b.ReportMetric(float64(b.Elapsed().Nanoseconds()/int64(b.N*batchSize*batchNum)), "ns/row")
}

0 comments on commit 162eb46

Please sign in to comment.