From fc2a1736ec84deffd20d673f3520fd1438f08a21 Mon Sep 17 00:00:00 2001 From: Sergio Benitez Date: Mon, 7 Jun 2021 19:26:21 -0700 Subject: [PATCH] Use stable, Windows compatible benchmarking. --- benchmarks/Cargo.toml | 8 ++++++-- benchmarks/src/bench.rs | 3 +++ benchmarks/src/main.rs | 11 ----------- benchmarks/src/routing.rs | 7 ++++--- 4 files changed, 13 insertions(+), 16 deletions(-) create mode 100644 benchmarks/src/bench.rs delete mode 100644 benchmarks/src/main.rs diff --git a/benchmarks/Cargo.toml b/benchmarks/Cargo.toml index ab1893f4..68bc82d2 100644 --- a/benchmarks/Cargo.toml +++ b/benchmarks/Cargo.toml @@ -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" diff --git a/benchmarks/src/bench.rs b/benchmarks/src/bench.rs new file mode 100644 index 00000000..8a76d89e --- /dev/null +++ b/benchmarks/src/bench.rs @@ -0,0 +1,3 @@ +mod routing; + +criterion::criterion_main!(routing::routing); diff --git a/benchmarks/src/main.rs b/benchmarks/src/main.rs deleted file mode 100644 index c0e4f470..00000000 --- a/benchmarks/src/main.rs +++ /dev/null @@ -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"); -} diff --git a/benchmarks/src/routing.rs b/benchmarks/src/routing.rs index 65411aaa..64d68491 100644 --- a/benchmarks/src/routing.rs +++ b/benchmarks/src/routing.rs @@ -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) -> Client { cli_colors: false, shutdown: config::Shutdown { ctrlc: false, + #[cfg(unix)] signals: HashSet::new(), ..Default::default() }, @@ -99,7 +100,6 @@ fn client(routes: Vec) -> 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);