This commit is contained in:
Sunli 2020-06-03 07:46:51 +08:00
commit 97f268a55e
3 changed files with 19 additions and 0 deletions

View File

@ -74,7 +74,18 @@ Ensure that there is no CPU-heavy process in background!
```shell script
cd benchmark
#measure all with system malloc
cargo bench
#measure only chat run
cargo bench -- "chat run"
#measure all with jemalloc
cargo bench --features jemalloc
#measure only simple run with jemalloc
cargo bench --features jemalloc -- "simple run"
```
Now HTML report is available at `benchmark/target/criterion/report`

View File

@ -10,12 +10,16 @@ futures = "0.3.4"
serde_json = "*"
async-graphql-parser = { path = "../async-graphql-parser" }
async-graphql = { path = ".." }
jemallocator = { version = "0.3.2", optional = true }
[dev-dependencies]
criterion = "0.3"
simple = { path = "simple" }
chat = { path = "chat" }
[features]
jemalloc = ["jemallocator"]
[[bench]]
name = "simple"
harness = false

View File

@ -3,6 +3,10 @@ use async_graphql::{ObjectType, QueryResponse, Schema, SubscriptionType};
use async_graphql_parser::{parse_query, query::Document};
use async_std::task;
#[cfg(feature = "jemalloc")]
#[global_allocator]
static ALLOC: jemallocator::Jemalloc = jemallocator::Jemalloc;
pub fn run<Query, Mutation, Subscription>(
s: &Schema<Query, Mutation, Subscription>,
q: &str,