Skip to content

Commit

Permalink
TC-1 (#359)
Browse files Browse the repository at this point in the history
add benchnew with confirmation-slot and confirmation-rate (TC-1 and TC-2)
  • Loading branch information
Lou-Kamades committed Mar 27, 2024
1 parent 7d39a94 commit 4f51c27
Show file tree
Hide file tree
Showing 15 changed files with 1,007 additions and 479 deletions.
19 changes: 19 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 4 additions & 1 deletion bench/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,13 @@ path = "src/main.rs"
[[bin]]
# WIP
name = "benchnew"
path = "src/cli.rs"
path = "src/benchnew.rs"

[dependencies]
clap = { workspace = true }
csv = "1.2.1"
dirs = "5.0.0"
solana-lite-rpc-util = { workspace = true }
solana-sdk = { workspace = true }
solana-rpc-client = { workspace = true }
solana-transaction-status = { workspace = true }
Expand All @@ -34,6 +35,8 @@ dashmap = { workspace = true }
bincode = { workspace = true }
itertools = "0.10.5"
spl-memo = "4.0.0"
url = "*"
reqwest = "0.11.26"
lazy_static = "1.4.0"

[dev-dependencies]
Expand Down
13 changes: 9 additions & 4 deletions bench/src/benches/api_load.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,12 @@ use solana_sdk::signature::{read_keypair_file, Keypair, Signer};
use crate::create_memo_tx_small;

// TC3 measure how much load the API endpoint can take
pub async fn api_load(payer_path: &Path, rpc_url: String, time_ms: u64) -> anyhow::Result<()> {
pub async fn api_load(
payer_path: &Path,
rpc_url: String,
test_duration_ms: u64,
cu_price_micro_lamports: u64,
) -> anyhow::Result<()> {
warn!("THIS IS WORK IN PROGRESS");

let rpc = Arc::new(RpcClient::new(rpc_url));
Expand All @@ -29,7 +34,7 @@ pub async fn api_load(payer_path: &Path, rpc_url: String, time_ms: u64) -> anyho
let hash = rpc.get_latest_blockhash().await?;
let time = tokio::time::Instant::now();

while time.elapsed().as_millis() < time_ms.into() {
while time.elapsed().as_millis() < test_duration_ms.into() {
let rpc = rpc.clone();
let payer = payer.clone();

Expand All @@ -40,7 +45,7 @@ pub async fn api_load(payer_path: &Path, rpc_url: String, time_ms: u64) -> anyho

tokio::spawn(async move {
let msg = msg.as_bytes();
let tx = create_memo_tx_small(msg, &payer, hash);
let tx = create_memo_tx_small(msg, &payer, hash, cu_price_micro_lamports);
match rpc.send_transaction(&tx).await {
Ok(_) => success.fetch_add(1, Ordering::Relaxed),
Err(_) => failed.fetch_add(1, Ordering::Relaxed),
Expand All @@ -50,7 +55,7 @@ pub async fn api_load(payer_path: &Path, rpc_url: String, time_ms: u64) -> anyho
txs += 1;
}

let calls_per_second = txs as f64 / (time_ms as f64 * 1000.0);
let calls_per_second = txs as f64 / (test_duration_ms as f64 * 1000.0);
info!("calls_per_second: {}", calls_per_second);
info!("failed: {}", failed.load(Ordering::Relaxed));
info!("success: {}", success.load(Ordering::Relaxed));
Expand Down
Loading

0 comments on commit 4f51c27

Please sign in to comment.