Skip to content

Commit

Permalink
A benchmark suite for the getTokenSupply RPC call
Browse files Browse the repository at this point in the history
  • Loading branch information
steveluscher committed Dec 11, 2024
1 parent 0431722 commit 331033e
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions accounts-cluster-bench/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -318,6 +318,7 @@ pub enum RpcBench {
Transaction,
TransactionParsed,
FirstAvailableBlock,
TokenSupply,
}

#[derive(Debug)]
Expand All @@ -339,6 +340,7 @@ impl FromStr for RpcBench {
"multiple-accounts" => Ok(RpcBench::MultipleAccounts),
"token-accounts-by-delegate" => Ok(RpcBench::TokenAccountsByDelegate),
"token-accounts-by-owner" => Ok(RpcBench::TokenAccountsByOwner),
"token-supply" => Ok(RpcBench::TokenSupply),
"transaction" => Ok(RpcBench::Transaction),
"transaction-parsed" => Ok(RpcBench::TransactionParsed),
"version" => Ok(RpcBench::Version),
Expand Down Expand Up @@ -701,6 +703,27 @@ fn run_rpc_bench_loop(
}
}
}
RpcBench::TokenSupply => {
let mut rpc_time = Measure::start("rpc-get-token-supply");
match client
.get_token_supply_with_commitment(&mint.unwrap(), CommitmentConfig::confirmed())
{
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.errors += 1;
stats.total_errors_time_us += rpc_time.as_us();
if last_error.elapsed().as_secs() > 2 {
info!("get-token-supply error: {:?}", e);
last_error = Instant::now();
}
}
}
}
RpcBench::Transaction => {
process_get_transaction(
"rpc-get-transaction-base64",
Expand Down Expand Up @@ -1264,6 +1287,7 @@ fn main() {
.requires_ifs(&[
("supply", "mint"),
("token-accounts-by-owner", "mint"),
("token-supply", "mint"),
])
.help("Spawn a thread which calls a specific RPC method in a loop to benchmark it"),
)
Expand Down

0 comments on commit 331033e

Please sign in to comment.