Skip to content

Commit f7bdf20

Browse files
committed
2 parents 4dcba41 + aa88b01 commit f7bdf20

File tree

3 files changed

+19
-0
lines changed

3 files changed

+19
-0
lines changed

README.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,18 @@ Ensure that there is no CPU-heavy process in background!
7474

7575
```shell script
7676
cd benchmark
77+
78+
#measure all with system malloc
7779
cargo bench
80+
81+
#measure only chat run
82+
cargo bench -- "chat run"
83+
84+
#measure all with jemalloc
85+
cargo bench --features jemalloc
86+
87+
#measure only simple run with jemalloc
88+
cargo bench --features jemalloc -- "simple run"
7889
```
7990

8091
Now HTML report is available at `benchmark/target/criterion/report`

benchmark/Cargo.toml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,16 @@ futures = "0.3.4"
1010
serde_json = "*"
1111
async-graphql-parser = { path = "../async-graphql-parser" }
1212
async-graphql = { path = ".." }
13+
jemallocator = { version = "0.3.2", optional = true }
1314

1415
[dev-dependencies]
1516
criterion = "0.3"
1617
simple = { path = "simple" }
1718
chat = { path = "chat" }
1819

20+
[features]
21+
jemalloc = ["jemallocator"]
22+
1923
[[bench]]
2024
name = "simple"
2125
harness = false

benchmark/src/lib.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,10 @@ use async_graphql::{ObjectType, QueryResponse, Schema, SubscriptionType};
33
use async_graphql_parser::{parse_query, query::Document};
44
use async_std::task;
55

6+
#[cfg(feature = "jemalloc")]
7+
#[global_allocator]
8+
static ALLOC: jemallocator::Jemalloc = jemallocator::Jemalloc;
9+
610
pub fn run<Query, Mutation, Subscription>(
711
s: &Schema<Query, Mutation, Subscription>,
812
q: &str,

0 commit comments

Comments
 (0)