Skip to content

Commit 647651e

Browse files
committed
chore: Implement benchmark for authorizer.Prepare
Identify time + alloc cost before optimizing
1 parent 049984c commit 647651e

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

coderd/rbac/authz_test.go

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -189,6 +189,17 @@ func BenchmarkRBACFilter(b *testing.B) {
189189
)
190190

191191
authorizer := rbac.NewAuthorizer(prometheus.NewRegistry())
192+
193+
for _, c := range benchCases {
194+
b.Run("PrepareOnly-"+c.Name, func(b *testing.B) {
195+
obType := rbac.ResourceWorkspace.Type
196+
for i := 0; i < b.N; i++ {
197+
_, err := authorizer.Prepare(context.Background(), c.Actor, rbac.ActionRead, obType)
198+
require.NoError(b, err)
199+
}
200+
})
201+
}
202+
192203
for _, c := range benchCases {
193204
b.Run(c.Name, func(b *testing.B) {
194205
objects := benchmarkSetup(orgs, users, b.N)

0 commit comments

Comments
 (0)