mirror of
https://github.com/coder/coder.git
synced 2025-07-03 16:13:58 +00:00
chore: Optimize parial rego execution byte allocations (#6144)
* chore: Implement benchmark for authorizer.Prepare Identify time + alloc cost before optimizing
This commit is contained in:
@ -189,6 +189,17 @@ func BenchmarkRBACFilter(b *testing.B) {
|
||||
)
|
||||
|
||||
authorizer := rbac.NewAuthorizer(prometheus.NewRegistry())
|
||||
|
||||
for _, c := range benchCases {
|
||||
b.Run("PrepareOnly-"+c.Name, func(b *testing.B) {
|
||||
obType := rbac.ResourceWorkspace.Type
|
||||
for i := 0; i < b.N; i++ {
|
||||
_, err := authorizer.Prepare(context.Background(), c.Actor, rbac.ActionRead, obType)
|
||||
require.NoError(b, err)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
for _, c := range benchCases {
|
||||
b.Run(c.Name, func(b *testing.B) {
|
||||
objects := benchmarkSetup(orgs, users, b.N)
|
||||
|
Reference in New Issue
Block a user