MCPcopy
hub / github.com/labstack/echo / BenchmarkRequestLogger_withoutMapFields

Function BenchmarkRequestLogger_withoutMapFields

middleware/request_logger_test.go:543–582  ·  view source on GitHub ↗
(b *testing.B)

Source from the content-addressed store, hash-verified

541}
542
543func BenchmarkRequestLogger_withoutMapFields(b *testing.B) {
544 e := echo.New()
545
546 mw := RequestLoggerWithConfig(RequestLoggerConfig{
547 Skipper: nil,
548 LogValuesFunc: func(c *echo.Context, values RequestLoggerValues) error {
549 return nil
550 },
551 LogLatency: true,
552 LogProtocol: true,
553 LogRemoteIP: true,
554 LogHost: true,
555 LogMethod: true,
556 LogURI: true,
557 LogURIPath: true,
558 LogRoutePath: true,
559 LogRequestID: true,
560 LogReferer: true,
561 LogUserAgent: true,
562 LogStatus: true,
563 LogContentLength: true,
564 LogResponseSize: true,
565 })(func(c *echo.Context) error {
566 c.Request().Header.Set(echo.HeaderXRequestID, "123")
567 return c.String(http.StatusTeapot, "OK")
568 })
569
570 req := httptest.NewRequest(http.MethodGet, "/test?lang=en", nil)
571 req.Header.Set("Referer", "https://echo.labstack.com/")
572 req.Header.Set("User-Agent", "curl/7.68.0")
573
574 b.ReportAllocs()
575 b.ResetTimer()
576
577 for i := 0; i < b.N; i++ {
578 rec := httptest.NewRecorder()
579 c := e.NewContext(req, rec)
580 mw(c)
581 }
582}
583
584func BenchmarkRequestLogger_withMapFields(b *testing.B) {
585 e := echo.New()

Callers

nothing calls this directly

Calls 5

RequestMethod · 0.95
StringMethod · 0.95
RequestLoggerWithConfigFunction · 0.85
SetMethod · 0.80
NewContextMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…