perf/throughput: Simplify benchmark output to CSV format

Remove verbose output from rusqlite benchmark and output only CSV
format: system,threads,batch_size,compute,throughput

This makes it easier to parse and plot benchmark results.
This commit is contained in:
Pekka Enberg
2025-10-01 09:49:29 +03:00
parent eeb14b25c6
commit 63895dfecd
4 changed files with 26 additions and 57 deletions

View File

@@ -0,0 +1,11 @@
#!/bin/sh
cargo build --release
echo "system,threads,batch_size,compute,throughput"
for threads in 1 2 4 8; do
for compute in 0 100 500 1000; do
../../../target/release/write-throughput-sqlite --threads ${threads} --batch-size 100 --compute ${compute} -i 1000
done
done

View File

@@ -28,11 +28,6 @@ struct Args {
fn main() -> Result<()> {
let args = Args::parse();
println!(
"Running write throughput benchmark with {} threads, {} batch size, {} iterations",
args.threads, args.batch_size, args.iterations
);
let db_path = "write_throughput_test.db";
if std::path::Path::new(db_path).exists() {
std::fs::remove_file(db_path).expect("Failed to remove existing database");
@@ -86,17 +81,9 @@ fn main() -> Result<()> {
let overall_elapsed = overall_start.elapsed();
let overall_throughput = (total_inserts as f64) / overall_elapsed.as_secs_f64();
println!("\n=== BENCHMARK RESULTS ===");
println!("Total inserts: {total_inserts}",);
println!("Total time: {:.2}s", overall_elapsed.as_secs_f64());
println!("Overall throughput: {overall_throughput:.2} inserts/sec");
println!("Threads: {}", args.threads);
println!("Batch size: {}", args.batch_size);
println!("Iterations per thread: {}", args.iterations);
println!(
"Database file exists: {}",
std::path::Path::new(db_path).exists()
"SQLite,{},{},{},{:.2}",
args.threads, args.batch_size, args.compute, overall_throughput
);
Ok(())
@@ -116,7 +103,6 @@ fn setup_database(db_path: &str) -> Result<Connection> {
[],
)?;
println!("Database created at: {db_path}");
Ok(conn)
}
@@ -134,7 +120,6 @@ fn worker_thread(
start_barrier.wait();
let start_time = Instant::now();
let mut total_inserts = 0;
for iteration in 0..iterations {
@@ -155,17 +140,6 @@ fn worker_thread(
conn.execute("COMMIT", [])?;
}
let elapsed = start_time.elapsed();
let throughput = (total_inserts as f64) / elapsed.as_secs_f64();
println!(
"Thread {}: {} inserts in {:.2}s ({:.2} inserts/sec)",
thread_id,
total_inserts,
elapsed.as_secs_f64(),
throughput
);
Ok(total_inserts)
}

View File

@@ -0,0 +1,11 @@
#!/bin/sh
cargo build --release
echo "system,threads,batch_size,compute,throughput"
for threads in 1 2 4 8; do
for compute in 0 100 500 1000; do
../../../target/release/write-throughput --threads ${threads} --batch-size 100 --compute ${compute} -i 1000 --mode concurrent
done
done

View File

@@ -61,11 +61,6 @@ async fn main() -> Result<()> {
.init();
let args = Args::parse();
println!(
"Running write throughput benchmark with {} threads, {} batch size, {} iterations, mode: {:?}",
args.threads, args.batch_size, args.iterations, args.mode
);
let db_path = "write_throughput_test.db";
if std::path::Path::new(db_path).exists() {
std::fs::remove_file(db_path).expect("Failed to remove existing database");
@@ -120,21 +115,10 @@ async fn main() -> Result<()> {
let overall_elapsed = overall_start.elapsed();
let overall_throughput = (total_inserts as f64) / overall_elapsed.as_secs_f64();
println!("\n=== BENCHMARK RESULTS ===");
println!("Total inserts: {total_inserts}");
println!("Total time: {:.2}s", overall_elapsed.as_secs_f64());
println!("Overall throughput: {overall_throughput:.2} inserts/sec");
println!("Threads: {}", args.threads);
println!("Batch size: {}", args.batch_size);
println!("Iterations per thread: {}", args.iterations);
println!(
"Database file exists: {}",
std::path::Path::new(db_path).exists()
"Turso,{},{},{},{:.2}",
args.threads, args.batch_size, args.compute, overall_throughput
);
if let Ok(metadata) = std::fs::metadata(db_path) {
println!("Database file size: {} bytes", metadata.len());
}
Ok(())
}
@@ -187,7 +171,6 @@ async fn worker_thread(
) -> Result<u64> {
start_barrier.wait();
let start_time = Instant::now();
let total_inserts = Arc::new(AtomicU64::new(0));
let mut tx_futs = vec![];
@@ -234,17 +217,7 @@ async fn worker_thread(
result?;
}
let elapsed = start_time.elapsed();
let final_inserts = total_inserts.load(Ordering::Relaxed);
let throughput = (final_inserts as f64) / elapsed.as_secs_f64();
println!(
"Thread {}: {} inserts in {:.2}s ({:.2} inserts/sec)",
thread_id,
final_inserts,
elapsed.as_secs_f64(),
throughput
);
Ok(final_inserts)
}