🧹 Add benchmark for Fresh with stale etag

This commit is contained in:
Larry Lv 2020-07-26 18:33:50 -07:00
parent fc85699a95
commit affd3469ba
No known key found for this signature in database
GPG Key ID: 8500335BD174D408

View File

@ -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()