2020-06-01 16:11:59 +00:00
|
|
|
use criterion::{black_box, criterion_group, criterion_main, Criterion};
|
2020-06-02 12:57:07 +00:00
|
|
|
use graphql_benchmark::{parse, run, serialize, GQLResponse};
|
|
|
|
use simple::{Q, S};
|
2020-06-01 16:05:37 +00:00
|
|
|
|
2020-06-02 12:57:07 +00:00
|
|
|
pub fn bench(c: &mut Criterion) {
|
|
|
|
c.bench_function("simple run", |b| b.iter(|| run(&S, black_box(Q))));
|
|
|
|
c.bench_function("simple parse", |b| b.iter(|| parse(black_box(Q))));
|
|
|
|
let res = GQLResponse(Ok(run(&S, Q)));
|
|
|
|
c.bench_function("simple serialize", |b| {
|
|
|
|
b.iter(|| serialize(black_box(&res)))
|
|
|
|
});
|
2020-06-01 16:05:37 +00:00
|
|
|
}
|
|
|
|
|
2020-06-02 12:57:07 +00:00
|
|
|
criterion_group!(simple, bench);
|
|
|
|
criterion_main!(simple);
|