-
Notifications
You must be signed in to change notification settings - Fork 8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
add context param query cache #1450
Conversation
Codecov Report
@@ Coverage Diff @@
## master #1450 +/- ##
==========================================
+ Coverage 98.75% 98.75% +<.01%
==========================================
Files 38 38
Lines 2160 2164 +4
==========================================
+ Hits 2133 2137 +4
Misses 15 15
Partials 12 12
Continue to review full report at Codecov.
|
why hasn't this change been merged? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
👍
Benchmark func BenchmarkGetQueryArrayOld(b *testing.B) {
c, _ := CreateTestContext(httptest.NewRecorder())
c.Request = createMultipartRequest()
var obj struct {
Foo string `form:"foo"`
Bar string `form:"bar"`
BarAsInt int `form:"bar"`
Array []string `form:"array"`
ID string `form:"id"`
TimeLocal time.Time `form:"time_local" time_format:"02/01/2006 15:04"`
TimeUTC time.Time `form:"time_utc" time_format:"02/01/2006 15:04" time_utc:"1"`
TimeLocation time.Time `form:"time_location" time_format:"02/01/2006 15:04" time_location:"Asia/Tokyo"`
BlankTime time.Time `form:"blank_time" time_format:"02/01/2006 15:04"`
}
c.Bind(&obj)
for i := 0; i < b.N; i++ {
c.GetQueryArray("array[]")
}
} result:
|
When we call the context.Query() function multiple times to get the parameter value, adding a cache can greatly reduce the number of calls for url.ParseQuery, which make a map for each call.