Only copy whats needed to verify an instruction after processing (#6669)
This commit is contained in:
@ -21,23 +21,34 @@ fn bench_verify_instruction_data(bencher: &mut Bencher) {
|
||||
|
||||
let owner = Pubkey::new_rand();
|
||||
let non_owner = Pubkey::new_rand();
|
||||
let pre = Account::new(0, BUFSIZE, &owner);
|
||||
let pre = PreInstructionAccount::new(
|
||||
&Account::new(0, BUFSIZE, &owner),
|
||||
true,
|
||||
need_account_data_checked(&owner, &owner, true),
|
||||
);
|
||||
let post = Account::new(0, BUFSIZE, &owner);
|
||||
assert_eq!(verify_instruction(true, &owner, &pre, &post), Ok(()));
|
||||
|
||||
bencher.iter(|| pre.data == post.data);
|
||||
let summary = bencher.bench(|_bencher| {}).unwrap();
|
||||
info!("data compare {} ns/iter", summary.median);
|
||||
assert_eq!(verify_instruction(&owner, &pre, &post), Ok(()));
|
||||
|
||||
// this one should be faster
|
||||
bencher.iter(|| {
|
||||
verify_instruction(true, &owner, &pre, &post).unwrap();
|
||||
verify_instruction(&owner, &pre, &post).unwrap();
|
||||
});
|
||||
let summary = bencher.bench(|_bencher| {}).unwrap();
|
||||
info!("data no change by owner: {} ns/iter", summary.median);
|
||||
|
||||
let pre = PreInstructionAccount::new(
|
||||
&Account::new(0, BUFSIZE, &owner),
|
||||
true,
|
||||
need_account_data_checked(&owner, &non_owner, true),
|
||||
);
|
||||
match pre.data {
|
||||
Some(ref data) => bencher.iter(|| *data == post.data),
|
||||
None => panic!("No data!"),
|
||||
}
|
||||
let summary = bencher.bench(|_bencher| {}).unwrap();
|
||||
info!("data compare {} ns/iter", summary.median);
|
||||
bencher.iter(|| {
|
||||
verify_instruction(true, &non_owner, &pre, &post).unwrap();
|
||||
verify_instruction(&non_owner, &pre, &post).unwrap();
|
||||
});
|
||||
let summary = bencher.bench(|_bencher| {}).unwrap();
|
||||
info!("data no change by non owner: {} ns/iter", summary.median);
|
||||
|
Reference in New Issue
Block a user