Skip to content

Commit

Permalink
Bench: Starting with benchmarks for producer...
Browse files Browse the repository at this point in the history
* Define bench for producer with async support
* Comment out `deny(unused_crate_dependencies)` because this lint can't
  differentiate between dev and none dev dependencies.
  • Loading branch information
AmmarAbouZor authored and marcmo committed Sep 18, 2024
1 parent 8347c31 commit 489ca61
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 1 deletion.
4 changes: 4 additions & 0 deletions application/apps/indexer/sources/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -28,3 +28,7 @@ shellexpand = "3.0.0"
[dev-dependencies]
env_logger.workspace = true
criterion = { workspace = true, features = ["async_tokio"] }

[[bench]]
name = "producer_benchmarks"
harness = false
19 changes: 19 additions & 0 deletions application/apps/indexer/sources/benches/producer_benchmarks.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
use criterion::{criterion_group, criterion_main, BenchmarkId, Criterion};

async fn produce(val: usize, val_2: usize) {
//TODO AAZ:
assert_eq!(val, val_2);
}

fn producer_benchmark(c: &mut Criterion) {
let val = 1024;

c.bench_with_input(BenchmarkId::new("producer", val), &val, |bencher, &v| {
bencher
.to_async(tokio::runtime::Runtime::new().unwrap())
.iter(|| produce(v, v));
});
}

criterion_group!(benches, producer_benchmark);
criterion_main!(benches);
5 changes: 4 additions & 1 deletion application/apps/indexer/sources/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
#![deny(unused_crate_dependencies)]
// TODO AAZ: Write better comment.
// This can't be used with benchmarks for now until issue "https://github.com/rust-lang/rust/issues/129637" is resolved.
// #![deny(unused_crate_dependencies)]

use thiserror::Error;

#[macro_use]
Expand Down

0 comments on commit 489ca61

Please sign in to comment.