MCPcopy
hub / github.com/gofiber/fiber / Benchmark_StartServices

Function Benchmark_StartServices

services_test.go:618–659  ·  view source on GitHub ↗
(b *testing.B)

Source from the content-addressed store, hash-verified

616}
617
618func Benchmark_StartServices(b *testing.B) {
619 benchmarkFn := func(b *testing.B, services []Service) {
620 b.Helper()
621
622 for b.Loop() {
623 app := New(Config{
624 Services: services,
625 })
626
627 ctx := context.Background()
628 if err := app.startServices(ctx); err != nil {
629 b.Fatal("Expected no error but got", err)
630 }
631 }
632 }
633
634 b.Run("no-services", func(b *testing.B) {
635 benchmarkFn(b, []Service{})
636 })
637
638 b.Run("single-service", func(b *testing.B) {
639 benchmarkFn(b, []Service{
640 &mockService{name: "dep1"},
641 })
642 })
643
644 b.Run("multiple-services", func(b *testing.B) {
645 benchmarkFn(b, []Service{
646 &mockService{name: "dep1"},
647 &mockService{name: "dep2"},
648 &mockService{name: "dep3"},
649 })
650 })
651
652 b.Run("multiple-services-with-delays", func(b *testing.B) {
653 benchmarkFn(b, []Service{
654 &mockService{name: "dep1", startDelay: 1 * time.Millisecond},
655 &mockService{name: "dep2", startDelay: 2 * time.Millisecond},
656 &mockService{name: "dep3", startDelay: 3 * time.Millisecond},
657 })
658 })
659}
660
661func Benchmark_ShutdownServices(b *testing.B) {
662 benchmarkFn := func(b *testing.B, services []Service) {

Callers

nothing calls this directly

Calls 3

startServicesMethod · 0.80
NewFunction · 0.70
FatalMethod · 0.65

Tested by

no test coverage detected