Synchronize benchmarks with core libraries.

This commit is contained in:
Sergio Benitez 2021-05-24 14:38:40 -07:00
parent faaa9c9065
commit b2519208a7
1 changed files with 16 additions and 6 deletions

View File

@ -1,11 +1,13 @@
use std::collections::hash_set::HashSet;
use criterion::Criterion;
use rocket::{handler, Request, Data, Route, Config};
use rocket::{route, config, Request, Data, Route, Config};
use rocket::http::{Method, RawStr, ContentType, Accept, Status};
use rocket::local::blocking::{Client, LocalRequest};
fn dummy_handler<'r>(req: &'r Request, _: Data) -> handler::HandlerFuture<'r> {
handler::Outcome::from(req, ()).pin()
fn dummy_handler<'r>(req: &'r Request, _: Data) -> route::BoxFuture<'r> {
route::Outcome::from(req, ()).pin()
}
fn parse_routes_table(table: &str) -> Vec<Route> {
@ -43,12 +45,16 @@ fn generate_matching_requests<'c>(client: &'c Client, routes: &[Route]) -> Vec<L
}
fn request_for_route<'c>(client: &'c Client, route: &Route) -> LocalRequest<'c> {
let path = route.uri.raw_path_segments()
let path = route.uri.origin.path()
.raw_segments()
.map(staticify_segment)
.collect::<Vec<_>>()
.join("/");
let query = route.uri.raw_query_segments()
let query = route.uri.origin.query()
.map(|q| q.raw_segments())
.into_iter()
.flatten()
.map(staticify_segment)
.collect::<Vec<_>>()
.join("&");
@ -76,7 +82,11 @@ fn client(routes: Vec<Route>) -> Client {
profile: Config::RELEASE_PROFILE,
log_level: rocket::config::LogLevel::Off,
cli_colors: false,
shutdown: config::Shutdown {
ctrlc: false,
signals: HashSet::new(),
..Default::default()
},
..Default::default()
};