use io_harness::{StepRecord, Store};
use std::time::Instant;
fn main() -> io_harness::Result<()> {
let iterations: u32 = std::env::args()
.nth(1)
.map(|a| a.parse().expect("iterations must be a positive integer"))
.unwrap_or(20_000);
let dir = tempfile::tempdir().expect("temp dir");
let store = Store::open(dir.path().join("throughput.db"))?;
let run_id = store.start_run("measure store write throughput", "src/lib.rs")?;
let prompt = "goal: measure store write throughput\n\
file: src/lib.rs\n\
step: apply the edit the model asked for, then verify\n\
context: the previous step wrote the file and the verify command failed\n";
let tool_call =
r#"{"name":"edit_file","arguments":{"path":"src/lib.rs","old":"fn a()","new":"fn b()"}}"#;
let start = Instant::now();
for step in 1..=iterations {
store.checkpoint_step(
run_id,
&StepRecord::new(step, "edit_file", "applied the edit")
.with_trace(prompt, tool_call, 1_280),
)?;
}
let elapsed = start.elapsed();
println!(
"store_throughput iterations={} elapsed_s={:.6} writes_per_sec={:.1}",
iterations,
elapsed.as_secs_f64(),
f64::from(iterations) / elapsed.as_secs_f64(),
);
Ok(())
}