-
Notifications
You must be signed in to change notification settings - Fork 10
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
15 changed files
with
305 additions
and
50 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -39,3 +39,4 @@ jobs: | |
run: | | ||
lua examples/example.lua | ||
lua examples/custom-matcher.lua | ||
lua examples/regular-expression.lua |
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 |
---|---|---|
@@ -1,3 +1,7 @@ | ||
unused_args = false | ||
max_line_length = false | ||
redefined = false | ||
|
||
globals = { | ||
"ngx", | ||
} |
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,33 @@ | ||
local Router = require "radix-router" | ||
local utils = require "benchmark.utils" | ||
|
||
local route_n = os.getenv("RADIX_ROUTER_ROUTES") or 1000 * 100 | ||
local times = os.getenv("RADIX_ROUTER_TIMES") or 1000 * 1000 * 10 | ||
|
||
local router | ||
do | ||
local routes = {} | ||
for i = 1, route_n do | ||
routes[i] = { paths = { string.format("/%d/{name:[^/]+}", i) }, handler = i } | ||
end | ||
router = Router.new(routes) | ||
end | ||
|
||
local rss_mb = utils.get_rss() | ||
|
||
local path = "/1/a" | ||
local elapsed = utils.timing(function() | ||
for _ = 1, times do | ||
router:match(path) | ||
end | ||
end) | ||
|
||
utils.print_result({ | ||
title = "regex", | ||
routes = route_n, | ||
times = times, | ||
elapsed = elapsed, | ||
benchmark_path = path, | ||
benchmark_handler = router:match(path), | ||
rss = rss_mb, | ||
}) |
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,12 @@ | ||
local Router = require "radix-router" | ||
local router, err = Router.new({ | ||
{ | ||
paths = { "/users/{id:\\d+}/profile-{year:\\d{4}}.{format:(html|pdf)}" }, | ||
handler = "1" | ||
}, | ||
}) | ||
if not router then | ||
error("failed to create router: " .. err) | ||
end | ||
|
||
assert("1" == router:match("/users/100/profile-2024.pdf")) |
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 |
---|---|---|
|
@@ -22,7 +22,7 @@ description = { | |
} | ||
|
||
dependencies = { | ||
"lua >= 5.1, < 5.5" | ||
"lrexlib-pcre2", | ||
} | ||
|
||
build = { | ||
|
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
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.