Use stable, Windows compatible benchmarking.

This commit is contained in:
Sergio Benitez 2021-06-07 19:26:21 -07:00
parent 333da45470
commit fc2a1736ec
4 changed files with 13 additions and 16 deletions

View File

@ -6,7 +6,11 @@ publish = false
[workspace]
[dependencies]
[[bench]]
name = "main"
path = "src/bench.rs"
harness = false
[dev-dependencies]
rocket = { path = "../core/lib/" }
criterion = "0.3"
criterion-macro = "0.3"

3
benchmarks/src/bench.rs Normal file
View File

@ -0,0 +1,3 @@
mod routing;
criterion::criterion_main!(routing::routing);

View File

@ -1,11 +0,0 @@
#![feature(custom_test_frameworks)]
#![test_runner(criterion::runner)]
#[cfg_attr(test, macro_use)]
extern crate criterion_macro;
#[cfg(test)] mod routing;
pub fn main() {
eprintln!("help: cargo bench");
}

View File

@ -1,6 +1,6 @@
use std::collections::hash_set::HashSet;
use criterion::Criterion;
use criterion::{criterion_group, Criterion};
use rocket::{route, config, Request, Data, Route, Config};
use rocket::http::{Method, RawStr, ContentType, Accept, Status};
@ -84,6 +84,7 @@ fn client(routes: Vec<Route>) -> Client {
cli_colors: false,
shutdown: config::Shutdown {
ctrlc: false,
#[cfg(unix)]
signals: HashSet::new(),
..Default::default()
},
@ -99,7 +100,6 @@ fn client(routes: Vec<Route>) -> Client {
}
}
#[criterion]
pub fn bench_rust_lang_routes(c: &mut Criterion) {
let table = include_str!("../static/rust-lang.routes");
let routes = parse_routes_table(table);
@ -113,7 +113,6 @@ pub fn bench_rust_lang_routes(c: &mut Criterion) {
}));
}
#[criterion]
pub fn bench_bitwarden_routes(c: &mut Criterion) {
let table = include_str!("../static/bitwarden_rs.routes");
let routes = parse_routes_table(table);
@ -126,3 +125,5 @@ pub fn bench_bitwarden_routes(c: &mut Criterion) {
}
}));
}
criterion_group!(routing, bench_rust_lang_routes, bench_bitwarden_routes);