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

Function Benchmark_Ctx_RenderLocals

ctx_test.go:7914–7934  ·  view source on GitHub ↗
(b *testing.B)

Source from the content-addressed store, hash-verified

7912}
7913
7914func Benchmark_Ctx_RenderLocals(b *testing.B) {
7915 engine := &testTemplateEngine{}
7916 err := engine.Load()
7917 require.NoError(b, err)
7918 app := New(Config{
7919 PassLocalsToViews: true,
7920 })
7921 app.config.Views = engine
7922 c := app.AcquireCtx(&fasthttp.RequestCtx{})
7923
7924 c.Locals("Title", "Hello, World!")
7925
7926 b.ReportAllocs()
7927
7928 for b.Loop() {
7929 err = c.Render("index.tmpl", Map{})
7930 }
7931
7932 require.NoError(b, err)
7933 require.Equal(b, "<h1>Hello, World!</h1>", string(c.Response().Body()))
7934}
7935
7936func Benchmark_Ctx_RenderViewBind(b *testing.B) {
7937 engine := &testTemplateEngine{}

Callers

nothing calls this directly

Calls 7

LoadMethod · 0.95
AcquireCtxMethod · 0.80
NewFunction · 0.70
LocalsMethod · 0.65
RenderMethod · 0.65
BodyMethod · 0.65
ResponseMethod · 0.65

Tested by

no test coverage detected