Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Fix compilation and running of command and deserialization benchmarks #511

Merged
merged 4 commits into from
Sep 17, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 4 additions & 7 deletions command-parser/benches/commands.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ use patricia_tree::PatriciaSet;
use std::{
borrow::Cow,
collections::{BTreeSet, HashSet},
iter::FromIterator,
};

fn btreeset(set: &BTreeSet<Cow<'static, str>>, needle: &str) {
Expand Down Expand Up @@ -77,7 +78,7 @@ fn criterion_benchmark(c: &mut Criterion) {
];

c.bench_function("c: btreeset", |b| {
let mut set = BTreeSet::from_iter(commands.iter().map(Cow::from));
let set = BTreeSet::from_iter(commands.iter().map(|e| Cow::from(*e)));

b.iter(|| {
for command in commands.iter() {
Expand All @@ -87,11 +88,7 @@ fn criterion_benchmark(c: &mut Criterion) {
});

c.bench_function("c: hashset", |b| {
let mut set = HashSet::from_iter(commands.iter().map(Cow::from));

for e in commands.iter() {
set.insert(Cow::from(*e));
}
let set = HashSet::from_iter(commands.iter().map(|e| Cow::from(*e)));

b.iter(|| {
for command in commands.iter() {
Expand All @@ -111,7 +108,7 @@ fn criterion_benchmark(c: &mut Criterion) {
});

c.bench_function("c: patricia_tree", |b| {
let mut set = PatriciaSet::from_iter(commands.iter());
let set = PatriciaSet::from_iter(commands.iter());

b.iter(|| {
for command in commands.iter() {
Expand Down
10 changes: 5 additions & 5 deletions model/benches/deserialization.rs
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ fn reaction() {
}
},
"message_id": "3",
"user_id": "4",
"user_id": "4"
}"#;

serde_json::from_str::<Reaction>(input).unwrap();
Expand Down Expand Up @@ -184,11 +184,11 @@ fn typing_start() {

fn criterion_benchmark(c: &mut Criterion) {
c.bench_function("gateway event role delete", |b| {
b.iter(gateway_event_role_delete())
b.iter(gateway_event_role_delete)
});
c.bench_function("member chunk", |b| b.iter(member_chunk()));
c.bench_function("reaction", |b| b.iter(reaction()));
c.bench_function("typing start", |b| b.iter(typing_start()));
c.bench_function("member chunk", |b| b.iter(member_chunk));
c.bench_function("reaction", |b| b.iter(reaction));
c.bench_function("typing start", |b| b.iter(typing_start));
}

criterion_group!(benches, criterion_benchmark);
Expand Down