-
Notifications
You must be signed in to change notification settings - Fork 322
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
1 parent
d32e638
commit 0a86455
Showing
5 changed files
with
26 additions
and
28 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 |
---|---|---|
@@ -1,25 +1,22 @@ | ||
// use criterion::{black_box, criterion_group, criterion_main, Criterion}; | ||
// use http_types::Method; | ||
// use tide::router::Router; | ||
use criterion::{black_box, criterion_group, criterion_main, Criterion}; | ||
use http_types::{Method, Request, Response, Url}; | ||
|
||
// fn criterion_benchmark(c: &mut Criterion) { | ||
// let mut router = Router::<()>::new(); | ||
// router.add( | ||
// "hello", | ||
// Method::Get, | ||
// Box::new(|_| async { Ok("hello world") }), | ||
// ); | ||
fn criterion_benchmark(c: &mut Criterion) { | ||
let mut app = tide::new(); | ||
app.at("/hello").get(|_| async { Ok("hello world") }); | ||
|
||
// c.bench_function("route-match", |b| { | ||
// b.iter(|| black_box(router.route("/hello", Method::Get))) | ||
// }); | ||
let route = Url::parse("https://example.com/hello").unwrap(); | ||
let req = Request::new(Method::Get, route); | ||
c.bench_function("route-match", |b| { | ||
b.iter(|| black_box(app.respond::<_, Response>(req.clone()))); | ||
}); | ||
|
||
// c.bench_function("route-root", |b| { | ||
// b.iter(|| black_box(router.route("", Method::Get))) | ||
// }); | ||
// } | ||
let route = Url::parse("https://example.com").unwrap(); | ||
let req = Request::new(Method::Get, route); | ||
c.bench_function("route-root", |b| { | ||
b.iter(|| black_box(app.respond::<_, Response>(req.clone()))); | ||
}); | ||
} | ||
|
||
// criterion_group!(benches, criterion_benchmark); | ||
// criterion_main!(benches); | ||
|
||
fn main() {} | ||
criterion_group!(benches, criterion_benchmark); | ||
criterion_main!(benches); |
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