Skip to content

Commit

Permalink
add close
Browse files Browse the repository at this point in the history
  • Loading branch information
KirillLykov committed Dec 13, 2024
1 parent 4051cfe commit bd3480a
Showing 1 changed file with 38 additions and 1 deletion.
39 changes: 38 additions & 1 deletion programs/bpf_loader/benches/bpf_loader_upgradeable.rs
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,31 @@ impl TestSetup {
bincode::serialize(&UpgradeableLoaderInstruction::SetAuthority).unwrap();
}

fn prep_close(&mut self) {
self.instruction_accounts = vec![
AccountMeta {
pubkey: self.buffer_address,
is_signer: false,
is_writable: true,
},
AccountMeta {
pubkey: self.authority_address,
is_signer: false,
is_writable: true,
},
AccountMeta {
pubkey: self.authority_address,
is_signer: true,
is_writable: false,
},
];

// lets use the same account for recipient and authority
self.transaction_accounts
.push(self.transaction_accounts[1].clone());
self.instruction_data = bincode::serialize(&UpgradeableLoaderInstruction::Close).unwrap();
}

fn run(&self) {
mock_process_instruction(
&self.loader_address,
Expand Down Expand Up @@ -337,11 +362,23 @@ fn bench_set_authority(c: &mut Criterion) {
});
}

fn bench_close(c: &mut Criterion) {
let mut test_setup = TestSetup::new();
test_setup.prep_close();

c.bench_function("close", |bencher| {
bencher.iter(|| {
test_setup.run();
})
});
}

criterion_group!(
benches,
bench_initialize_buffer,
bench_write,
bench_upgradeable_upgrade,
bench_set_authority
bench_set_authority,
bench_close
);
criterion_main!(benches);

0 comments on commit bd3480a

Please sign in to comment.