-
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
7 changed files
with
180 additions
and
3 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 |
---|---|---|
@@ -1 +1,2 @@ | ||
unused_args = false | ||
max_line_length = false |
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,34 @@ | ||
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("/aa/{bb}/cc/{dd}/ee/{ff}/gg/{hh}/ii/{jj}/kk/{ll}/mm/{nn}/oo/{pp}/qq/{rr}/ss/{tt}/uu/{vv}/ww/{xx}/yy/zz%d", i) | ||
}, handler = i } | ||
end | ||
router = Router.new(routes) | ||
end | ||
|
||
local path = "/aa/bb/cc/dd/ee/ff/gg/hh/ii/jj/kk/ll/mm/nn/oo/pp/qq/rr/ss/tt/uu/vv/ww/xx/yy/zz" .. route_n / 2 | ||
|
||
local elapsed = utils.timing(function() | ||
for _ = 1, times do | ||
router:match(path) | ||
end | ||
end) | ||
|
||
utils.print_result({ | ||
title = "variable", | ||
routes = route_n, | ||
times = times, | ||
elapsed = elapsed, | ||
benchmark_path = path, | ||
benchmark_handler = router:match(path), | ||
}) |
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,34 @@ | ||
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 path = "/1/foo" | ||
local params = {} | ||
|
||
local elapsed = utils.timing(function() | ||
for _ = 1, times do | ||
router:match(path, nil, params) | ||
end | ||
end) | ||
|
||
utils.print_result({ | ||
title = "variable", | ||
routes = route_n, | ||
times = times, | ||
elapsed = elapsed, | ||
benchmark_path = path, | ||
benchmark_handler = router:match(path), | ||
}, { | ||
{ name = "params", value = string.format("name = " .. params.name) } | ||
}) |
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,31 @@ | ||
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", i) }, handler = i } | ||
end | ||
router = Router.new(routes) | ||
end | ||
|
||
local path = "/" .. route_n / 2 | ||
|
||
local elapsed = utils.timing(function() | ||
for _ = 1, times do | ||
router:match(path) | ||
end | ||
end) | ||
|
||
utils.print_result({ | ||
title = "static path", | ||
routes = route_n, | ||
times = times, | ||
elapsed = elapsed, | ||
benchmark_path = path, | ||
benchmark_handler = router:match(path), | ||
}) |
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