mirror of
https://github.com/gofiber/fiber.git
synced 2025-05-31 11:52:41 +00:00
Add benchmark
This commit is contained in:
parent
8db7e169a3
commit
4102262dd7
@ -199,6 +199,24 @@ func registerDummyRoutes(app *App) {
|
||||
}
|
||||
}
|
||||
|
||||
// go test -v -run=^$ -bench=Benchmark_App_Benchmark_App_MethodNotAllowed -benchmem -count=4
|
||||
func Benchmark_App_MethodNotAllowed(b *testing.B) {
|
||||
app := New()
|
||||
app.Get("/this/is/a/dummy/route/oke", func(c *Ctx) {
|
||||
c.Send("Hello World!")
|
||||
})
|
||||
c := &fasthttp.RequestCtx{}
|
||||
|
||||
c.Request.Header.SetMethod("DELETE")
|
||||
c.URI().SetPath("/this/is/a/dummy/route/oke")
|
||||
|
||||
for n := 0; n < b.N; n++ {
|
||||
app.handler(c)
|
||||
}
|
||||
utils.AssertEqual(b, 405, c.Response.StatusCode())
|
||||
utils.AssertEqual(b, "GET, HEAD", string(c.Response.Header.Peek("Allow")))
|
||||
}
|
||||
|
||||
// go test -v ./... -run=^$ -bench=Benchmark_Router_NotFound -benchmem -count=4
|
||||
func Benchmark_Router_NotFound(b *testing.B) {
|
||||
app := New()
|
||||
|
Loading…
x
Reference in New Issue
Block a user