Skip to content

Commit

Permalink
add benchmark for multiple transactions
Browse files Browse the repository at this point in the history
  • Loading branch information
joonazan committed Jul 23, 2024
1 parent 26ddf4e commit 616e324
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 1 deletion.
4 changes: 4 additions & 0 deletions core/tests/vm-benchmark/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,10 @@ harness = false
name = "iai"
harness = false

[[bench]]
name = "fill_bootloader"
harness = false

[[bin]]
name = "iai_results_to_prometheus"
path = "src/iai_results_to_prometheus.rs"
Expand Down
24 changes: 24 additions & 0 deletions core/tests/vm-benchmark/benches/fill_bootloader.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
use std::time::Instant;

use criterion::black_box;
use vm_benchmark_harness::{
cut_to_allowed_bytecode_size, get_deploy_tx_with_gas_limit, BenchmarkingVm,
};

fn main() {
let test_contract =
std::fs::read("deployment_benchmarks/event_spam").expect("failed to read file");

let code = cut_to_allowed_bytecode_size(&test_contract).unwrap();
let tx = get_deploy_tx_with_gas_limit(code, 1000);

let start = Instant::now();

let mut vm = BenchmarkingVm::new();
for _ in 0..1000 {
vm.run_transaction(black_box(&tx));
dbg!("tx");
}

println!("{:?}", start.elapsed());
}
6 changes: 5 additions & 1 deletion core/tests/vm-benchmark/harness/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,10 @@ impl BenchmarkingVm {
}

pub fn get_deploy_tx(code: &[u8]) -> Transaction {
get_deploy_tx_with_gas_limit(code, 30_000_000)
}

pub fn get_deploy_tx_with_gas_limit(code: &[u8], gas_limit: u32) -> Transaction {
let params = [
Token::FixedBytes(vec![0u8; 32]),
Token::FixedBytes(hash_bytecode(code).0.to_vec()),
Expand All @@ -133,7 +137,7 @@ pub fn get_deploy_tx(code: &[u8]) -> Transaction {
calldata,
Nonce(0),
Fee {
gas_limit: U256::from(30000000u32),
gas_limit: U256::from(gas_limit),
max_fee_per_gas: U256::from(250_000_000),
max_priority_fee_per_gas: U256::from(0),
gas_per_pubdata_limit: U256::from(get_max_gas_per_pubdata_byte(
Expand Down

0 comments on commit 616e324

Please sign in to comment.