Skip to content

Commit 7a4bfa3

Browse files
committed
A benchmark suite for the getTokenSupply RPC call
1 parent ccb3cd3 commit 7a4bfa3

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

accounts-cluster-bench/src/main.rs

+24
Original file line numberDiff line numberDiff line change
@@ -318,6 +318,7 @@ pub enum RpcBench {
318318
Transaction,
319319
TransactionParsed,
320320
FirstAvailableBlock,
321+
TokenSupply,
321322
}
322323

323324
#[derive(Debug)]
@@ -339,6 +340,7 @@ impl FromStr for RpcBench {
339340
"multiple-accounts" => Ok(RpcBench::MultipleAccounts),
340341
"token-accounts-by-delegate" => Ok(RpcBench::TokenAccountsByDelegate),
341342
"token-accounts-by-owner" => Ok(RpcBench::TokenAccountsByOwner),
343+
"token-supply" => Ok(RpcBench::TokenSupply),
342344
"transaction" => Ok(RpcBench::Transaction),
343345
"transaction-parsed" => Ok(RpcBench::TransactionParsed),
344346
"version" => Ok(RpcBench::Version),
@@ -701,6 +703,27 @@ fn run_rpc_bench_loop(
701703
}
702704
}
703705
}
706+
RpcBench::TokenSupply => {
707+
let mut rpc_time = Measure::start("rpc-get-token-supply");
708+
match client
709+
.get_token_supply_with_commitment(&mint.unwrap(), CommitmentConfig::confirmed())
710+
{
711+
Ok(_ui_token_amount) => {
712+
rpc_time.stop();
713+
stats.success += 1;
714+
stats.total_success_time_us += rpc_time.as_us();
715+
}
716+
Err(e) => {
717+
rpc_time.stop();
718+
stats.errors += 1;
719+
stats.total_errors_time_us += rpc_time.as_us();
720+
if last_error.elapsed().as_secs() > 2 {
721+
info!("get-token-supply error: {:?}", e);
722+
last_error = Instant::now();
723+
}
724+
}
725+
}
726+
}
704727
RpcBench::Transaction => {
705728
process_get_transaction(
706729
"rpc-get-transaction-base64",
@@ -1264,6 +1287,7 @@ fn main() {
12641287
.requires_ifs(&[
12651288
("supply", "mint"),
12661289
("token-accounts-by-owner", "mint"),
1290+
("token-supply", "mint"),
12671291
])
12681292
.help("Spawn a thread which calls a specific RPC method in a loop to benchmark it"),
12691293
)

0 commit comments

Comments
 (0)