MCPcopy Index your code
hub / github.com/coder/coder / benchmarkSetup

Function benchmarkSetup

coderd/rbac/authz_test.go:265–286  ·  view source on GitHub ↗
(orgs []uuid.UUID, users []uuid.UUID, size int, opts ...func(object rbac.Object) rbac.Object)

Source from the content-addressed store, hash-verified

263}
264
265func benchmarkSetup(orgs []uuid.UUID, users []uuid.UUID, size int, opts ...func(object rbac.Object) rbac.Object) []rbac.Object {
266 // Create a "random" but deterministic set of objects.
267 aclList := map[string][]policy.Action{
268 uuid.NewString(): {policy.ActionRead, policy.ActionUpdate},
269 uuid.NewString(): {policy.ActionCreate},
270 }
271 objectList := make([]rbac.Object, size)
272 for i := range objectList {
273 objectList[i] = rbac.ResourceWorkspace.
274 WithID(uuid.New()).
275 InOrg(orgs[i%len(orgs)]).
276 WithOwner(users[i%len(users)].String()).
277 WithACLUserList(aclList).
278 WithGroupACL(aclList)
279
280 for _, opt := range opts {
281 objectList[i] = opt(objectList[i])
282 }
283 }
284
285 return objectList
286}
287
288// BenchmarkCacher benchmarks the performance of the cacher.
289func BenchmarkCacher(b *testing.B) {

Callers 3

BenchmarkRBACAuthorizeFunction · 0.85
BenchmarkRBACFilterFunction · 0.85

Calls 7

WithGroupACLMethod · 0.80
WithACLUserListMethod · 0.80
WithOwnerMethod · 0.80
InOrgMethod · 0.80
NewMethod · 0.65
WithIDMethod · 0.45
StringMethod · 0.45

Tested by

no test coverage detected