@@ -318,6 +318,7 @@ pub enum RpcBench {
318
318
Transaction ,
319
319
TransactionParsed ,
320
320
FirstAvailableBlock ,
321
+ TokenSupply ,
321
322
}
322
323
323
324
#[ derive( Debug ) ]
@@ -339,6 +340,7 @@ impl FromStr for RpcBench {
339
340
"multiple-accounts" => Ok ( RpcBench :: MultipleAccounts ) ,
340
341
"token-accounts-by-delegate" => Ok ( RpcBench :: TokenAccountsByDelegate ) ,
341
342
"token-accounts-by-owner" => Ok ( RpcBench :: TokenAccountsByOwner ) ,
343
+ "token-supply" => Ok ( RpcBench :: TokenSupply ) ,
342
344
"transaction" => Ok ( RpcBench :: Transaction ) ,
343
345
"transaction-parsed" => Ok ( RpcBench :: TransactionParsed ) ,
344
346
"version" => Ok ( RpcBench :: Version ) ,
@@ -701,6 +703,27 @@ fn run_rpc_bench_loop(
701
703
}
702
704
}
703
705
}
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
+ }
704
727
RpcBench :: Transaction => {
705
728
process_get_transaction (
706
729
"rpc-get-transaction-base64" ,
@@ -1264,6 +1287,7 @@ fn main() {
1264
1287
. requires_ifs ( & [
1265
1288
( "supply" , "mint" ) ,
1266
1289
( "token-accounts-by-owner" , "mint" ) ,
1290
+ ( "token-supply" , "mint" ) ,
1267
1291
] )
1268
1292
. help ( "Spawn a thread which calls a specific RPC method in a loop to benchmark it" ) ,
1269
1293
)
0 commit comments