Skip to content

Commit

Permalink
server: add benchmark for ReplicaMatrix endpoint
Browse files Browse the repository at this point in the history
Benchstat output: (count=10)

name                     time/op
AdminAPIReplicaMatrix-8  385ms ±84%

Benchmark count -10 output:

goos: darwin
goarch: amd64
pkg: github.com/cockroachdb/cockroach/pkg/server
BenchmarkAdminAPIReplicaMatrix-8   	      10	 168937559 ns/op
BenchmarkAdminAPIReplicaMatrix-8   	      10	 432137334 ns/op
BenchmarkAdminAPIReplicaMatrix-8   	      10	 168379098 ns/op
BenchmarkAdminAPIReplicaMatrix-8   	      10	 177149986 ns/op
BenchmarkAdminAPIReplicaMatrix-8   	       5	 206646397 ns/op
BenchmarkAdminAPIReplicaMatrix-8   	      10	 182270207 ns/op
BenchmarkAdminAPIReplicaMatrix-8   	      10	 170547378 ns/op
BenchmarkAdminAPIReplicaMatrix-8   	       5	 204531985 ns/op
BenchmarkAdminAPIReplicaMatrix-8   	      10	 172730136 ns/op
BenchmarkAdminAPIReplicaMatrix-8   	      10	 165367664 ns/op
PASS
ok  	github.com/cockroachdb/cockroach/pkg/server	113.757s

Release note: None
  • Loading branch information
Pete Vilter committed Apr 13, 2018
1 parent 9887c8c commit 250a4f1
Showing 1 changed file with 28 additions and 0 deletions.
28 changes: 28 additions & 0 deletions pkg/server/admin_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1432,3 +1432,31 @@ func TestAdminAPIReplicaMatrix(t *testing.T) {
return nil
})
}

func BenchmarkAdminAPIReplicaMatrix(b *testing.B) {
testCluster := serverutils.StartTestCluster(b, 3, base.TestClusterArgs{})
defer testCluster.Stopper().Stop(context.Background())

firstServer := testCluster.Server(0)
sqlDB := sqlutils.MakeSQLRunner(testCluster.ServerConn(0))

sqlDB.Exec(b, `CREATE DATABASE roachblog`)

// Create a bunch of tables.
for i := 0; i < 200; i++ {
sqlDB.Exec(
b,
fmt.Sprintf(`CREATE TABLE roachblog.t%d (id INT PRIMARY KEY, title text, body text)`, i),
)
// TODO(vilterp): split to increase the number of ranges for each table
}

b.ResetTimer()
for n := 0; n < b.N; n++ {
var resp serverpb.ReplicaMatrixResponse
if err := getAdminJSONProto(firstServer, "replica_matrix", &resp); err != nil {
b.Fatal(err)
}
}
b.StopTimer()
}

0 comments on commit 250a4f1

Please sign in to comment.