Add basic merge and nest benchmarks

This commit is contained in:
David Pedersen 2023-04-12 19:14:16 +02:00
parent cf1ed9bb54
commit 377d73a55b

View file

@ -19,7 +19,20 @@ fn main() {
benchmark("minimal").run(Router::new); benchmark("minimal").run(Router::new);
benchmark("basic").run(|| Router::new().route("/", get(|| async { "Hello, World!" }))); benchmark("basic")
.path("/a/b/c")
.run(|| Router::new().route("/a/b/c", get(|| async { "Hello, World!" })));
benchmark("basic-merge").path("/a/b/c").run(|| {
let inner = Router::new().route("/a/b/c", get(|| async { "Hello, World!" }));
Router::new().merge(inner)
});
benchmark("basic-nest").path("/a/b/c").run(|| {
let c = Router::new().route("/c", get(|| async { "Hello, World!" }));
let b = Router::new().nest("/b", c);
Router::new().nest("/a", b)
});
benchmark("routing").path("/foo/bar/baz").run(|| { benchmark("routing").path("/foo/bar/baz").run(|| {
let mut app = Router::new(); let mut app = Router::new();