diff --git a/accounts-cluster-bench/src/main.rs b/accounts-cluster-bench/src/main.rs index a465d0c07a1dc8..b71ad96e400626 100644 --- a/accounts-cluster-bench/src/main.rs +++ b/accounts-cluster-bench/src/main.rs @@ -254,6 +254,7 @@ pub enum RpcBench { MultipleAccounts, ProgramAccounts, TokenAccountsByOwner, + Supply, TokenAccountsByDelegate, } @@ -268,6 +269,7 @@ impl FromStr for RpcBench { fn from_str(s: &str) -> Result { match s { "slot" => Ok(RpcBench::Slot), + "supply" => Ok(RpcBench::Supply), "multiple-accounts" => Ok(RpcBench::MultipleAccounts), "token-accounts-by-delegate" => Ok(RpcBench::TokenAccountsByDelegate), "token-accounts-by-owner" => Ok(RpcBench::TokenAccountsByOwner), @@ -407,6 +409,25 @@ fn run_rpc_bench_loop( } } } + RpcBench::Supply => { + let mut rpc_time = Measure::start("rpc-get-token-supply"); + match client.get_token_supply(&mint.unwrap()) { + Ok(_ui_token_amount) => { + 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_token_supply error: {:?}", e); + last_error = Instant::now(); + } + } + } + } RpcBench::MultipleAccounts => { process_get_multiple_accounts( max_closed, @@ -1005,6 +1026,7 @@ fn main() { .value_name("RPC_BENCH_TYPE(S)") .multiple(true) .requires_ifs(&[ + ("supply", "mint"), ("token-accounts-by-owner", "mint"), ]) .help("Spawn a thread which calls a specific RPC method in a loop to benchmark it"),