-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
10 changed files
with
255 additions
and
98 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
local radix = require("router-tree") | ||
local route_count = 1000 * 100 | ||
local match_times = 1000 * 1000 * 10 | ||
|
||
local routes = {} | ||
for i = 1, route_count do | ||
routes[i] = {paths = {"/user" .. i .. "/:name"}, metadata = i} | ||
end | ||
|
||
local opts = {matched = {}} | ||
local rx = radix.new(routes) | ||
|
||
ngx.update_time() | ||
local start_time = ngx.now() | ||
|
||
local res | ||
local path = "/user1/gordon" | ||
for _ = 1, match_times do | ||
res = rx:match(path, opts) | ||
end | ||
|
||
ngx.update_time() | ||
local used_time = ngx.now() - start_time | ||
ngx.say("matched res: ", res) | ||
ngx.say("route count: ", route_count) | ||
ngx.say("match times: ", match_times) | ||
ngx.say("time used : ", used_time, " sec") | ||
ngx.say("QPS : ", math.floor(match_times / used_time)) | ||
ngx.say("each time : ", used_time * 1000 * 1000 / match_times, " ns") |
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Oops, something went wrong.