Skip to content

Commit

Permalink
A benchmark suite for the getTokenSupply RPC call (#3981)
Browse files Browse the repository at this point in the history
  • Loading branch information
steveluscher authored Dec 9, 2024
1 parent de77e17 commit 6c362f6
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions accounts-cluster-bench/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -254,6 +254,7 @@ pub enum RpcBench {
MultipleAccounts,
ProgramAccounts,
TokenAccountsByOwner,
Supply,
TokenAccountsByDelegate,
}

Expand All @@ -268,6 +269,7 @@ impl FromStr for RpcBench {
fn from_str(s: &str) -> Result<Self, Self::Err> {
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),
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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"),
Expand Down

0 comments on commit 6c362f6

Please sign in to comment.