Skip to content

Commit

Permalink
chore(starknet_gateway): create bench file for benchmark test
Browse files Browse the repository at this point in the history
  • Loading branch information
ArniStarkware committed Dec 26, 2024
1 parent 2a1b6aa commit d46eac5
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 0 deletions.
1 change: 1 addition & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions crates/starknet_gateway/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ validator.workspace = true
[dev-dependencies]
assert_matches.workspace = true
cairo-lang-sierra-to-casm.workspace = true
criterion.workspace = true
mockall.workspace = true
mockito.workspace = true
num-bigint.workspace = true
Expand All @@ -49,3 +50,8 @@ rstest.workspace = true
starknet_mempool.workspace = true
starknet_mempool_types = { workspace = true, features = ["testing"] }
tracing-test.workspace = true

[[bench]]
harness = false
name = "gateway_bench"
path = "bench/gateway_bench.rs"
37 changes: 37 additions & 0 deletions crates/starknet_gateway/bench/gateway_bench.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
//! Benchmark module for the starknet gateway crate. It provides functionalities to benchmark
//! the performance of the gateway service, including declare, deploy account and invoke
//! transactions.
//!
//! There are four benchmark functions in this flow: `declare_benchmark`,
//! `deploy_account_benchmark`, `invoke_benchmark` and `gateway_benchmark` which combines all of the
//! types. Each of the functions measure the performance of the gateway handling randomly created
//! txs of the respective type.
//!
//! Run the benchmarks using `cargo bench --bench gateway_bench`.
use criterion::{criterion_group, criterion_main, Criterion};

pub fn declare_benchmark(c: &mut Criterion) {
c.bench_function("declares", |benchmark| benchmark.iter(|| {}));
}

pub fn deploy_account_benchmark(c: &mut Criterion) {
c.bench_function("deploy_accounts", |benchmark| benchmark.iter(|| {}));
}

pub fn invoke_benchmark(c: &mut Criterion) {
c.bench_function("invokes", |benchmark| benchmark.iter(|| {}));
}

pub fn gateway_benchmark(c: &mut Criterion) {
c.bench_function("all_transaction_types", |benchmark| benchmark.iter(|| {}));
}

criterion_group!(
benches,
declare_benchmark,
deploy_account_benchmark,
invoke_benchmark,
gateway_benchmark
);
criterion_main!(benches);

0 comments on commit d46eac5

Please sign in to comment.