Use bencher crate to run benchmarks on stable rust
This commit is contained in:
parent
7a0439bad7
commit
96c1ad0ef9
3 changed files with 19 additions and 12 deletions
|
@ -9,6 +9,11 @@ repository = "https://github.com/mhallin/juniper"
|
|||
readme = "README.md"
|
||||
keywords = ["graphql", "server", "iron", "http", "web"]
|
||||
|
||||
[[bench]]
|
||||
name = "bench"
|
||||
harness = false
|
||||
path = "benches/bench.rs"
|
||||
|
||||
[features]
|
||||
default = []
|
||||
nightly = []
|
||||
|
@ -25,3 +30,4 @@ router = "^0.2.0"
|
|||
mount = "^0.2.1"
|
||||
logger = "^0.1.0"
|
||||
iron-test = "^0.4.0"
|
||||
bencher = "^0.1.2"
|
||||
|
|
|
@ -1,14 +1,16 @@
|
|||
use test::Bencher;
|
||||
#[macro_use] extern crate bencher;
|
||||
extern crate juniper;
|
||||
|
||||
use bencher::Bencher;
|
||||
|
||||
use std::collections::{HashMap};
|
||||
|
||||
use schema::model::RootNode;
|
||||
use tests::model::Database;
|
||||
use juniper::{execute, RootNode, EmptyMutation};
|
||||
use juniper::tests::model::Database;
|
||||
|
||||
#[bench]
|
||||
fn query_type_name(b: &mut Bencher) {
|
||||
let database = Database::new();
|
||||
let schema = RootNode::new(&database, ());
|
||||
let schema = RootNode::new(&database, EmptyMutation::<Database>::new());
|
||||
|
||||
let doc = r#"
|
||||
query IntrospectionQueryTypeQuery {
|
||||
|
@ -19,13 +21,12 @@ fn query_type_name(b: &mut Bencher) {
|
|||
}
|
||||
}"#;
|
||||
|
||||
b.iter(|| ::execute(doc, None, &schema, &HashMap::new(), &database));
|
||||
b.iter(|| execute(doc, None, &schema, &HashMap::new(), &database));
|
||||
}
|
||||
|
||||
#[bench]
|
||||
fn introspection_query(b: &mut Bencher) {
|
||||
let database = Database::new();
|
||||
let schema = RootNode::new(&database, ());
|
||||
let schema = RootNode::new(&database, EmptyMutation::<Database>::new());
|
||||
|
||||
let doc = r#"
|
||||
query IntrospectionQuery {
|
||||
|
@ -121,5 +122,8 @@ fn introspection_query(b: &mut Bencher) {
|
|||
}
|
||||
"#;
|
||||
|
||||
b.iter(|| ::execute(doc, None, &schema, &HashMap::new(), &database));
|
||||
b.iter(|| execute(doc, None, &schema, &HashMap::new(), &database));
|
||||
}
|
||||
|
||||
benchmark_group!(queries, query_type_name, introspection_query);
|
||||
benchmark_main!(queries);
|
|
@ -2,6 +2,3 @@ pub mod model;
|
|||
mod schema;
|
||||
pub mod query_tests;
|
||||
pub mod introspection_tests;
|
||||
|
||||
#[cfg(feature="nightly")]
|
||||
pub mod bench;
|
||||
|
|
Loading…
Reference in a new issue