go test -v ./... -run=^$ -bench=Benchmark_Router_NotFound -benchmem -count=4
(b *testing.B)
| 1530 | |
| 1531 | // go test -v ./... -run=^$ -bench=Benchmark_Router_NotFound -benchmem -count=4 |
| 1532 | func Benchmark_Router_NotFound(b *testing.B) { |
| 1533 | b.ReportAllocs() |
| 1534 | app := New() |
| 1535 | app.Use(func(c Ctx) error { |
| 1536 | return c.Next() |
| 1537 | }) |
| 1538 | registerDummyRoutes(app) |
| 1539 | appHandler := app.Handler() |
| 1540 | c := &fasthttp.RequestCtx{} |
| 1541 | |
| 1542 | c.Request.Header.SetMethod("DELETE") |
| 1543 | c.URI().SetPath("/this/route/does/not/exist") |
| 1544 | |
| 1545 | for b.Loop() { |
| 1546 | appHandler(c) |
| 1547 | } |
| 1548 | require.Equal(b, 404, c.Response.StatusCode()) |
| 1549 | require.Equal(b, "Not Found", string(c.Response.Body())) |
| 1550 | } |
| 1551 | |
| 1552 | // go test -v ./... -run=^$ -bench=Benchmark_Router_Handler -benchmem -count=4 |
| 1553 | func Benchmark_Router_Handler(b *testing.B) { |
nothing calls this directly
no test coverage detected