From a1067214782ef1e95fbbb7210635bce5ccdf9323 Mon Sep 17 00:00:00 2001 From: Andrew Werner Date: Mon, 10 Oct 2022 11:17:15 -0400 Subject: [PATCH] sql: fix BenchmarkGetZoneConfig Some of the test setup was in the loop and all of the cost was in that setup. After this change, the benchmark takes 90ns and no allocations. Release note: None --- pkg/sql/zone_config_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/sql/zone_config_test.go b/pkg/sql/zone_config_test.go index 04a76b95be6a..c6e88d30d9ac 100644 --- a/pkg/sql/zone_config_test.go +++ b/pkg/sql/zone_config_test.go @@ -657,9 +657,9 @@ func BenchmarkGetZoneConfig(b *testing.B) { s := srv.(*server.TestServer) cfg := forceNewConfig(b, s) + key := roachpb.RKey(keys.SystemSQLCodec.TablePrefix(bootstrap.TestingUserDescID(0))) b.ResetTimer() for i := 0; i < b.N; i++ { - key := roachpb.RKey(keys.SystemSQLCodec.TablePrefix(bootstrap.TestingUserDescID(0))) _, _, err := config.TestingGetSystemTenantZoneConfigForKey(cfg, key) if err != nil { b.Fatal(err)