MCPcopy Create free account
hub / github.com/Permify/permify / BenchmarkRequestCollection

Function BenchmarkRequestCollection

internal/engines/bulk_benchmark_test.go:100–141  ·  view source on GitHub ↗

BenchmarkRequestCollection tests the performance of request collection

(b *testing.B)

Source from the content-addressed store, hash-verified

98
99// BenchmarkRequestCollection tests the performance of request collection
100func BenchmarkRequestCollection(b *testing.B) {
101 ctx := context.Background()
102 checker := &MockChecker{}
103
104 config := BulkCheckerConfig{
105 ConcurrencyLimit: 10,
106 BufferSize: 10000,
107 }
108
109 callback := func(id, ct string) {}
110
111 b.ResetTimer()
112 b.ReportAllocs()
113
114 for b.Loop() {
115 bc, err := NewBulkChecker(ctx, checker, BulkCheckerTypeEntity, callback, config)
116 if err != nil {
117 b.Fatal(err)
118 }
119
120 publisher := NewBulkEntityPublisher(ctx, &base.PermissionLookupEntityRequest{
121 TenantId: "test",
122 Metadata: &base.PermissionLookupEntityRequestMetadata{},
123 EntityType: "document",
124 Permission: "read",
125 Subject: &base.Subject{Id: "user1"},
126 }, bc)
127
128 // Publish requests rapidly
129 for j := 0; j < 10000; j++ {
130 publisher.Publish(
131 &base.Entity{Id: fmt.Sprintf("doc%d", j)},
132 &base.PermissionCheckRequestMetadata{},
133 &base.Context{},
134 base.CheckResult_CHECK_RESULT_UNSPECIFIED,
135 )
136 }
137
138 bc.StopCollectingRequests()
139 bc.Close()
140 }
141}
142
143// BenchmarkSorting tests the performance of request sorting
144func BenchmarkSorting(b *testing.B) {

Callers

nothing calls this directly

Calls 5

PublishMethod · 0.95
CloseMethod · 0.95
NewBulkCheckerFunction · 0.85
NewBulkEntityPublisherFunction · 0.85

Tested by

no test coverage detected