diff --git a/accounts-cluster-bench/src/main.rs b/accounts-cluster-bench/src/main.rs index b71ad96e400626..dfd89dbdffb4d5 100644 --- a/accounts-cluster-bench/src/main.rs +++ b/accounts-cluster-bench/src/main.rs @@ -256,6 +256,7 @@ pub enum RpcBench { TokenAccountsByOwner, Supply, TokenAccountsByDelegate, + AccountInfo, } #[derive(Debug)] @@ -268,6 +269,7 @@ impl FromStr for RpcBench { fn from_str(s: &str) -> Result { match s { + "account-info" => Ok(RpcBench::AccountInfo), "slot" => Ok(RpcBench::Slot), "supply" => Ok(RpcBench::Supply), "multiple-accounts" => Ok(RpcBench::MultipleAccounts), @@ -390,6 +392,35 @@ fn run_rpc_bench_loop( break; } match rpc_bench { + RpcBench::AccountInfo => { + let start: u64 = max_closed.load(Ordering::Relaxed); + let end: u64 = max_created.load(Ordering::Relaxed); + let seed_range = start..end; + if seed_range.is_empty() { + info!("get_account_info: No accounts have yet been created; skipping"); + continue; + } + let seed = thread_rng().gen_range(seed_range).to_string(); + let account_pubkey = + Pubkey::create_with_seed(base_keypair_pubkey, &seed, program_id).unwrap(); + let mut rpc_time = Measure::start("rpc-get-account-info"); + match client.get_account(&account_pubkey) { + Ok(_account) => { + rpc_time.stop(); + stats.success += 1; + stats.total_success_time_us += rpc_time.as_us(); + } + Err(e) => { + rpc_time.stop(); + stats.total_errors_time_us += rpc_time.as_us(); + stats.errors += 1; + if last_error.elapsed().as_secs() > 2 { + info!("get_account_info error: {:?}", e); + last_error = Instant::now(); + } + } + } + } RpcBench::Slot => { let mut rpc_time = Measure::start("rpc-get-slot"); match client.get_slot() {