mirror of https://github.com/rwf2/Rocket.git
Backport benchmarks.
This commit is contained in:
parent
7fa99b75dd
commit
f0a7206694
|
@ -4,7 +4,6 @@
|
|||
extern crate rocket;
|
||||
|
||||
use rocket::config::{Environment, Config};
|
||||
use rocket::http::RawStr;
|
||||
|
||||
#[get("/", format = "application/json")]
|
||||
fn get() -> &'static str { "get" }
|
||||
|
@ -26,21 +25,7 @@ mod benches {
|
|||
use self::test::Bencher;
|
||||
use rocket::testing::MockRequest;
|
||||
use rocket::http::Method::*;
|
||||
use rocket::http::{Accept, ContentType};
|
||||
|
||||
#[bench]
|
||||
fn accept_format(b: &mut Bencher) {
|
||||
let rocket = rocket();
|
||||
let mut request = MockRequest::new(Get, "/").header(Accept::JSON);
|
||||
b.iter(|| { request.dispatch_with(&rocket); });
|
||||
}
|
||||
|
||||
#[bench]
|
||||
fn wrong_accept_format(b: &mut Bencher) {
|
||||
let rocket = rocket();
|
||||
let mut request = MockRequest::new(Get, "/").header(Accept::HTML);
|
||||
b.iter(|| { request.dispatch_with(&rocket); });
|
||||
}
|
||||
use rocket::http::ContentType;
|
||||
|
||||
#[bench]
|
||||
fn content_type_format(b: &mut Bencher) {
|
||||
|
|
|
@ -4,7 +4,6 @@
|
|||
extern crate rocket;
|
||||
|
||||
use rocket::config::{Environment, Config};
|
||||
use rocket::http::RawStr;
|
||||
|
||||
#[get("/", format = "application/json")]
|
||||
fn get() -> &'static str { "json" }
|
||||
|
@ -39,22 +38,22 @@ mod benches {
|
|||
use self::test::Bencher;
|
||||
use rocket::testing::MockRequest;
|
||||
use rocket::http::Method::*;
|
||||
use rocket::http::{Accept, ContentType};
|
||||
use rocket::http::ContentType;
|
||||
|
||||
#[bench]
|
||||
fn accept_format(b: &mut Bencher) {
|
||||
let rocket = rocket();
|
||||
let mut requests = vec![];
|
||||
requests.push(MockRequest::new(Get, "/").header(Accept::JSON));
|
||||
requests.push(MockRequest::new(Get, "/").header(Accept::HTML));
|
||||
requests.push(MockRequest::new(Get, "/").header(Accept::Plain));
|
||||
// #[bench]
|
||||
// fn accept_format(b: &mut Bencher) {
|
||||
// let rocket = rocket();
|
||||
// let mut requests = vec![];
|
||||
// requests.push(MockRequest::new(Get, "/").header(Accept::JSON));
|
||||
// requests.push(MockRequest::new(Get, "/").header(Accept::HTML));
|
||||
// requests.push(MockRequest::new(Get, "/").header(Accept::Plain));
|
||||
|
||||
b.iter(|| {
|
||||
for request in requests.iter_mut() {
|
||||
request.dispatch_with(&rocket);
|
||||
}
|
||||
});
|
||||
}
|
||||
// b.iter(|| {
|
||||
// for request in requests.iter_mut() {
|
||||
// request.dispatch_with(&rocket);
|
||||
// }
|
||||
// });
|
||||
// }
|
||||
|
||||
#[bench]
|
||||
fn content_type_format(b: &mut Bencher) {
|
||||
|
|
|
@ -4,7 +4,6 @@
|
|||
extern crate rocket;
|
||||
|
||||
use rocket::config::{Environment, Config};
|
||||
use rocket::http::RawStr;
|
||||
|
||||
#[get("/")]
|
||||
fn get_index() -> &'static str { "index" }
|
||||
|
@ -25,7 +24,7 @@ fn index_b() -> &'static str { "index" }
|
|||
fn index_c() -> &'static str { "index" }
|
||||
|
||||
#[get("/<a>")]
|
||||
fn index_dyn_a(a: &RawStr) -> &'static str { "index" }
|
||||
fn index_dyn_a(a: &str) -> &'static str { "index" }
|
||||
|
||||
fn rocket() -> rocket::Rocket {
|
||||
let config = Config::new(Environment::Production).unwrap();
|
||||
|
|
Loading…
Reference in New Issue