mirror of
https://github.com/gofiber/fiber.git
synced 2025-05-31 11:52:41 +00:00
🧹 Add benchmark for Fresh with stale etag
This commit is contained in:
parent
fc85699a95
commit
affd3469ba
17
ctx_test.go
17
ctx_test.go
@ -632,6 +632,23 @@ func Test_Ctx_FormValue(t *testing.T) {
|
||||
utils.AssertEqual(t, StatusOK, resp.StatusCode, "Status code")
|
||||
}
|
||||
|
||||
// go test -v -run=^$ -bench=Benchmark_Ctx_Fresh_StaleEtag -benchmem -count=4
|
||||
func Benchmark_Ctx_Fresh_StaleEtag(b *testing.B) {
|
||||
app := New()
|
||||
ctx := app.AcquireCtx(&fasthttp.RequestCtx{})
|
||||
defer app.ReleaseCtx(ctx)
|
||||
|
||||
for n := 0; n < b.N; n++ {
|
||||
ctx.Fasthttp.Request.Header.Set(HeaderIfNoneMatch, "a, b, c, d")
|
||||
ctx.Fasthttp.Request.Header.Set(HeaderCacheControl, "c")
|
||||
ctx.Fresh()
|
||||
|
||||
ctx.Fasthttp.Request.Header.Set(HeaderIfNoneMatch, "a, b, c, d")
|
||||
ctx.Fasthttp.Request.Header.Set(HeaderCacheControl, "e")
|
||||
ctx.Fresh()
|
||||
}
|
||||
}
|
||||
|
||||
// go test -run Test_Ctx_Fresh
|
||||
func Test_Ctx_Fresh(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
Loading…
x
Reference in New Issue
Block a user