Skip to content

Commit

Permalink
replace interval_duration_micros by requests_per_second as an argumen…
Browse files Browse the repository at this point in the history
…t for native token transaction benchmark

Issue [12835](#12835).
Using "requests-per-second" instead of suggested "transactions_per_second" as this value can be used to limit the rate of the other requests to the network as well (client data sync for example).
Renamed the corresponding parameter in the `bencmark_mpc_sign` as well.
  • Loading branch information
ssavenko-near committed Jan 30, 2025
1 parent 94abfca commit ee676af
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
5 changes: 2 additions & 3 deletions benchmarks/synth-bm/src/contract.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ pub struct BenchmarkMpcSignArgs {
/// The number of transactions to send per second. May be lower when reaching hardware limits or
/// network congestion.
#[arg(long)]
pub transactions_per_second: u64,
pub requests_per_second: u64,
/// The total number of transactions to send.
#[arg(long)]
pub num_transactions: u64,
Expand Down Expand Up @@ -61,8 +61,7 @@ pub async fn benchmark_mpc_sign(args: &BenchmarkMpcSignArgs) -> anyhow::Result<(
);

// Pick interval to achieve desired TPS.
let mut interval =
time::interval(Duration::from_micros(1_000_000 / args.transactions_per_second));
let mut interval = time::interval(Duration::from_micros(1_000_000 / args.requests_per_second));

let client = JsonRpcClient::connect(&args.rpc_url);
let block_service = Arc::new(BlockService::new(client.clone()).await);
Expand Down
9 changes: 5 additions & 4 deletions benchmarks/synth-bm/src/native_transfer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,11 @@ pub struct BenchmarkArgs {
/// Acts as upper bound on the number of concurrently open RPC requests.
#[arg(long)]
pub channel_buffer_size: usize,
/// After each tick (in microseconds) a transaction is sent. If the hardware cannot keep up with
/// that or if the NEAR node is congested, transactions are sent at a slower rate.

/// Upper bound on request rate to the network for transaction (and other auxiliary) calls. The actual rate may be lower in case of congestions.
#[arg(long)]
pub interval_duration_micros: u64,
pub requests_per_second: u64,

#[arg(long)]
pub amount: u128,
}
Expand All @@ -39,7 +40,7 @@ pub async fn benchmark(args: &BenchmarkArgs) -> anyhow::Result<()> {
let mut accounts = accounts_from_dir(&args.user_data_dir)?;
assert!(accounts.len() >= 2);

let mut interval = time::interval(Duration::from_micros(args.interval_duration_micros));
let mut interval = time::interval(Duration::from_micros(1_000_000 / args.requests_per_second));
let timer = Instant::now();

let between = Uniform::from(0..accounts.len());
Expand Down

0 comments on commit ee676af

Please sign in to comment.