Skip to content

Commit

Permalink
Replace N with the size check
Browse files Browse the repository at this point in the history
  • Loading branch information
xgreenx committed Nov 22, 2023
1 parent f8449cb commit 5de31e9
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions benches/benches/vm_initialization.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,8 @@ fn transaction<R: Rng>(
rng: &mut R,
script: Vec<u8>,
script_data: Vec<u8>,
consensus_params: &ConsensusParameters,
) -> Checked<Script> {
let consensus_params = ConsensusParameters::default();
let inputs = (0..1)
.map(|_| {
Input::coin_predicate(
Expand Down Expand Up @@ -83,15 +83,18 @@ pub fn vm_initialization(c: &mut Criterion) {

let mut group = c.benchmark_group("vm_initialization");

// Generate N data points
const N: usize = 18;
for i in 5..N {
let consensus_params = ConsensusParameters::default();
let mut i = 5usize;
loop {
let size = 8 * (1 << i);
if size as u64 > consensus_params.script_params.max_script_data_length {
break
}
let script = vec![op::ret(1); size / Instruction::SIZE]
.into_iter()
.collect();
let script_data = vec![255; size];
let tx = transaction(&mut rng, script, script_data);
let tx = transaction(&mut rng, script, script_data, &consensus_params);
let tx_size = tx.transaction().size();
let name = format!("vm_initialization_with_tx_size_{}", tx_size);
group.throughput(Throughput::Bytes(tx_size as u64));
Expand All @@ -104,6 +107,7 @@ pub fn vm_initialization(c: &mut Criterion) {
.expect("Should be able to execute transaction");
})
});
i += 1;
}

group.finish();
Expand Down

0 comments on commit 5de31e9

Please sign in to comment.