-
Notifications
You must be signed in to change notification settings - Fork 606
chore(route): remove useless code from tree #793
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
Merged
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## develop #793 +/- ##
========================================
Coverage 73.68% 73.68%
========================================
Files 145 145
Lines 16860 16860
========================================
Hits 12423 12423
Misses 3848 3848
Partials 589 589 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
thanks |
welkeyever
reviewed
May 29, 2023
zh: 修改后, 寻找 any 节点的速度比之前快了一倍 BenchMark code func BenchmarkFindAnyParam(b *testing.B) {
var isNil bool
tree := &router{method: "GET", root: &node{}}
routes := [...]string{
"/hi/hello/test/*any",
"/b",
"/ABC",
"/search/*query",
"/src/*filepath",
"/x",
"/x/y",
"/y/z",
"/1/:id/2",
"/aa",
"/a/*any",
"/doc",
"/doc/go1.html",
"/doc/go/away",
"/no/a",
"/no/b",
"/z/:age",
"/x/3/4",
"/x/:age/5",
}
for _, route := range routes {
recv := catchPanic(func() {
tree.addRoute(route, fakeHandler(route))
})
if recv != nil {
b.Fatalf("panic inserting route '%s': %v", route, recv)
}
}
v := make(param.Params, 0, 10)
b.ResetTimer()
for n := 0; n < b.N; n++ {
value := tree.find("/hi/hello/test/sth", &v, false)
if value.handlers == nil {
isNil = true
} else {
isNil = false
}
}
b.StopTimer()
assert.DeepEqual(b, isNil, false)
} before: goos: linux
goarch: amd64
pkg: github.com/cloudwego/hertz/pkg/route
cpu: Intel(R) Core(TM) i5-1035G1 CPU @ 1.00GHz
BenchmarkFindAnyParam
BenchmarkFindAnyParam-2 26044662 49.24 ns/op
PASS after change: goos: linux
goarch: amd64
pkg: github.com/cloudwego/hertz/pkg/route
cpu: Intel(R) Core(TM) i5-1035G1 CPU @ 1.00GHz
BenchmarkFindAnyParam
BenchmarkFindAnyParam-2 49172884 23.27 ns/op
PASS |
Duslia
reviewed
Sep 19, 2023
xiaost
approved these changes
May 27, 2025
jayantxie
approved these changes
May 27, 2025
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
What type of PR is this?
chore
Check the PR title.
<type>(optional scope): <description>
.(Optional) Translate the PR title into Chinese.
去除 tree 中 find AnyParam 节点中无意义的代码