Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

release-23.1: bench: ignore cluster startup and shutdown #117907

Merged
merged 1 commit into from
Jan 18, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions pkg/bench/foreachdb.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,14 @@ var runSepProcessTenant = flag.Bool("run-sep-process-tenant", false, "run separa
// BenchmarkFn is a function that runs a benchmark using the given SQLRunner.
type BenchmarkFn func(b *testing.B, db *sqlutils.SQLRunner)

// timerUtil is a helper method that should be called right before the
// invocation of BenchmarkFn and the returned function should be deferred.
func timerUtil(b *testing.B) func() {
b.ResetTimer()
b.StartTimer()
return b.StopTimer
}

func benchmarkCockroach(b *testing.B, f BenchmarkFn) {
s, db, _ := serverutils.StartServer(
b, base.TestServerArgs{
Expand All @@ -55,6 +63,7 @@ func benchmarkCockroach(b *testing.B, f BenchmarkFn) {
b.Fatal(err)
}

defer timerUtil(b)()
f(b, sqlutils.MakeSQLRunner(db))
}

Expand Down Expand Up @@ -104,6 +113,7 @@ func benchmarkSharedProcessTenantCockroach(b *testing.B, f BenchmarkFn) {
_, err = tenantDB.Exec(`CREATE DATABASE bench`)
require.NoError(b, err)

defer timerUtil(b)()
f(b, sqlutils.MakeSQLRunner(tenantDB))
}

Expand Down Expand Up @@ -134,6 +144,7 @@ func benchmarkSepProcessTenantCockroach(b *testing.B, f BenchmarkFn) {
_, err = tenantDB.Exec(`CREATE DATABASE bench`)
require.NoError(b, err)

defer timerUtil(b)()
f(b, sqlutils.MakeSQLRunner(tenantDB))
}

Expand All @@ -151,6 +162,7 @@ func benchmarkMultinodeCockroach(b *testing.B, f BenchmarkFn) {
}
defer tc.Stopper().Stop(context.TODO())

defer timerUtil(b)()
f(b, sqlutils.MakeRoundRobinSQLRunner(tc.Conns[0], tc.Conns[1], tc.Conns[2]))
}

Expand Down Expand Up @@ -199,6 +211,7 @@ func benchmarkPostgres(b *testing.B, f BenchmarkFn) {
r := sqlutils.MakeSQLRunner(db)
r.Exec(b, `CREATE SCHEMA IF NOT EXISTS bench`)

defer timerUtil(b)()
f(b, r)
}

Expand All @@ -219,6 +232,7 @@ func benchmarkMySQL(b *testing.B, f BenchmarkFn) {
r := sqlutils.MakeSQLRunner(db)
r.Exec(b, `CREATE DATABASE IF NOT EXISTS bench`)

defer timerUtil(b)()
f(b, r)
}

Expand Down