Benchmark_StartServices_withContextCancellation() — fiber Function Reference
Architecture documentation for the Benchmark_StartServices_withContextCancellation() function in services_test.go from the fiber codebase.
Entity Profile
Dependency Diagram
graph TD 678828d4_43bf_e5fe_670f_0cd02dbdeeb9["Benchmark_StartServices_withContextCancellation()"] a3b050d2_f10a_df85_e082_e3ac664a6a6c["services_test.go"] 678828d4_43bf_e5fe_670f_0cd02dbdeeb9 -->|defined in| a3b050d2_f10a_df85_e082_e3ac664a6a6c style 678828d4_43bf_e5fe_670f_0cd02dbdeeb9 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
services_test.go lines 593–646
func Benchmark_StartServices_withContextCancellation(b *testing.B) {
benchmarkFn := func(b *testing.B, services []Service, timeout time.Duration) {
b.Helper()
for b.Loop() {
app := New(Config{
Services: services,
})
ctx, cancel := context.WithTimeout(context.Background(), timeout)
err := app.startServices(ctx)
// We expect an error here due to the short timeout
if err == nil && timeout < time.Second {
b.Fatal("Expected error due to context cancellation but got none")
}
cancel()
}
}
b.Run("single-service/immediate-cancellation", func(b *testing.B) {
benchmarkFn(b, []Service{
&mockService{name: "dep1", startDelay: 100 * time.Millisecond},
}, 10*time.Millisecond)
})
b.Run("multiple-services/immediate-cancellation", func(b *testing.B) {
benchmarkFn(b, []Service{
&mockService{name: "dep1", startDelay: 100 * time.Millisecond},
&mockService{name: "dep2", startDelay: 200 * time.Millisecond},
&mockService{name: "dep3", startDelay: 300 * time.Millisecond},
}, 10*time.Millisecond)
})
b.Run("multiple-services/successful-completion", func(b *testing.B) {
const timeout = 500 * time.Millisecond
for b.Loop() {
app := New(Config{
Services: []Service{
&mockService{name: "dep1", startDelay: 10 * time.Millisecond},
&mockService{name: "dep2", startDelay: 20 * time.Millisecond},
&mockService{name: "dep3", startDelay: 30 * time.Millisecond},
},
})
ctx, cancel := context.WithTimeout(context.Background(), timeout)
err := app.startServices(ctx)
if err != nil {
b.Fatal("Expected no error but got", err)
}
cancel()
}
})
}
Domain
Subdomains
Defined In
Source
Frequently Asked Questions
What does Benchmark_StartServices_withContextCancellation() do?
Benchmark_StartServices_withContextCancellation() is a function in the fiber codebase, defined in services_test.go.
Where is Benchmark_StartServices_withContextCancellation() defined?
Benchmark_StartServices_withContextCancellation() is defined in services_test.go at line 593.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free