-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
00226bb
commit 1197538
Showing
4 changed files
with
203 additions
and
3 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
use criterion::{criterion_group, criterion_main, Criterion}; | ||
use mango_feeds_connector::chain_data::{update_slotvec_logic, AccountData}; | ||
use solana_sdk::account::AccountSharedData; | ||
use solana_sdk::pubkey::Pubkey; | ||
use std::hint::black_box; | ||
|
||
fn given_v1235(dummy_account_data: AccountSharedData) -> Vec<AccountData> { | ||
vec![ | ||
AccountData { | ||
slot: 10, | ||
write_version: 10010, | ||
account: dummy_account_data.clone(), | ||
}, | ||
AccountData { | ||
slot: 20, | ||
write_version: 10020, | ||
account: dummy_account_data.clone(), | ||
}, | ||
AccountData { | ||
slot: 30, | ||
write_version: 10030, | ||
account: dummy_account_data.clone(), | ||
}, | ||
// no 40 | ||
AccountData { | ||
slot: 50, | ||
write_version: 10050, | ||
account: dummy_account_data.clone(), | ||
}, | ||
] | ||
} | ||
|
||
fn criterion_benchmark(c: &mut Criterion) { | ||
// overwrite if an entry for the slot already exists, otherwise insert | ||
let dummy_account_data = AccountSharedData::new(99999999, 999999, &Pubkey::new_unique()); | ||
let v = given_v1235(dummy_account_data); | ||
|
||
c.bench_function("update_slotvec_logic", |b| { | ||
b.iter(|| update_slotvec_logic(black_box(&v), 40, 10040)) | ||
}); | ||
} | ||
|
||
criterion_group!(benches, criterion_benchmark); | ||
criterion_main!(benches); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters