Skip to content

Commit

Permalink
Add restriction on the number of benchmarks running in parallel.
Browse files Browse the repository at this point in the history
Try to fix ProgramNotActivated error.
  • Loading branch information
qalisander committed Nov 28, 2024
1 parent 797a5a3 commit 99065ab
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 6 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.

1 change: 1 addition & 0 deletions benches/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,4 @@ koba.workspace = true
e2e.workspace = true
serde = "1.0.203"
keccak-const = "0.2.0"
itertools = "0.13.0"
21 changes: 15 additions & 6 deletions benches/src/main.rs
Original file line number Diff line number Diff line change
@@ -1,22 +1,31 @@
use benches::{
access_control, erc1155, erc20, erc721, merkle_proofs, ownable,
access_control, erc1155, erc20, erc721, merkle_proofs, ownable, report,

Check warning on line 2 in benches/src/main.rs

View workflow job for this annotation

GitHub Actions / Gas usage report

unused import: `report`
report::BenchmarkReport,
};
use futures::FutureExt;
use itertools::Itertools;

#[tokio::main]
async fn main() -> eyre::Result<()> {
let report = futures::future::try_join_all([
let benchmarks = [
access_control::bench().boxed(),
erc20::bench().boxed(),
erc721::bench().boxed(),
merkle_proofs::bench().boxed(),
ownable::bench().boxed(),
erc1155::bench().boxed(),
])
.await?
.into_iter()
.fold(BenchmarkReport::default(), BenchmarkReport::merge_with);
];

// Run benchmarks max 3 at the same time.
// Otherwise, nitro test node can overload and revert transaction.
const MAX_PARALLEL: usize = 3;
let mut report = BenchmarkReport::default();
for chunk in &benchmarks.into_iter().chunks(MAX_PARALLEL) {
report = futures::future::try_join_all(chunk)
.await?
.into_iter()
.fold(report, BenchmarkReport::merge_with);
}

println!();
println!("{report}");
Expand Down

0 comments on commit 99065ab

Please sign in to comment.