mirror of https://github.com/gofiber/fiber.git
🧹 chore: Add Immutable benchmarks for default case (#3374)
Add benchmarks for default case with Immutablepull/3378/head
parent
4bf292945d
commit
dab20c9df5
|
@ -656,6 +656,50 @@ func Benchmark_Router_Next_Default_Parallel(b *testing.B) {
|
|||
})
|
||||
}
|
||||
|
||||
// go test -v ./... -run=^$ -bench=Benchmark_Router_Next_Default_Immutable -benchmem -count=4
|
||||
func Benchmark_Router_Next_Default_Immutable(b *testing.B) {
|
||||
app := New(Config{Immutable: true})
|
||||
app.Get("/", func(_ Ctx) error {
|
||||
return nil
|
||||
})
|
||||
|
||||
h := app.Handler()
|
||||
|
||||
fctx := &fasthttp.RequestCtx{}
|
||||
fctx.Request.Header.SetMethod(MethodGet)
|
||||
fctx.Request.SetRequestURI("/")
|
||||
|
||||
b.ReportAllocs()
|
||||
b.ResetTimer()
|
||||
|
||||
for n := 0; n < b.N; n++ {
|
||||
h(fctx)
|
||||
}
|
||||
}
|
||||
|
||||
// go test -benchmem -run=^$ -bench ^Benchmark_Router_Next_Default_Parallel_Immutable$ github.com/gofiber/fiber/v3 -count=1
|
||||
func Benchmark_Router_Next_Default_Parallel_Immutable(b *testing.B) {
|
||||
app := New(Config{Immutable: true})
|
||||
app.Get("/", func(_ Ctx) error {
|
||||
return nil
|
||||
})
|
||||
|
||||
h := app.Handler()
|
||||
|
||||
b.ReportAllocs()
|
||||
b.ResetTimer()
|
||||
|
||||
b.RunParallel(func(pb *testing.PB) {
|
||||
fctx := &fasthttp.RequestCtx{}
|
||||
fctx.Request.Header.SetMethod(MethodGet)
|
||||
fctx.Request.SetRequestURI("/")
|
||||
|
||||
for pb.Next() {
|
||||
h(fctx)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
// go test -v ./... -run=^$ -bench=Benchmark_Route_Match -benchmem -count=4
|
||||
func Benchmark_Route_Match(b *testing.B) {
|
||||
var match bool
|
||||
|
|
Loading…
Reference in New Issue