drill
drill copied to clipboard
Stats on the iteration level
Hi, how about statistics on the iteration level?
An iteration is a single execution of a plan/scenario composed of one or more actions, it might represent a real world scenario, for example, the HTTP requests made behind the scenes by the backend when an user clicks on a button in a web app.
Thus I think it can be interesting to have a measure of the total time an iteration takes and eventually some statistics about it like median, average, percentiles...
I made a little POC and the main change would be in src/benchmark.rs
(see below), we now need to also return the duration of the iteration from the run_iteration
function, and this could be implemented with a new structure: IterationResult
. Of course this also implies some changes in various places in the code especially on how the reports are read in order to produce statistics.
pub struct BenchmarkResult {
- pub reports: Vec<Reports>,
+ pub reports: Vec<IterationResult>,
pub duration: f64,
}
-async fn run_iteration(benchmark: Arc<Benchmark>, pool: Pool, config: Arc<Config>, iteration: i64) -> Vec<Report> {
+pub struct IterationResult {
+ pub reports: Vec<Report>,
+ pub duration: f64,
+}
+
+async fn run_iteration(benchmark: Arc<Benchmark>, pool: Pool, config: Arc<Config>, iteration: i64) -> IterationResult {
if config.rampup > 0 {
let delay = config.rampup / config.iterations;
delay_for(Duration::new((delay * iteration) as u64, 0)).await;
}
let mut context: Context = Context::new();
let mut reports: Vec<Report> = Vec::new();
context.insert("iteration".to_string(), json!(iteration.to_string()));
context.insert("base".to_string(), json!(config.base.to_string()));
+ let begin = Instant::now();
for item in benchmark.iter() {
item.execute(&mut context, &mut reports, &pool, &config).await;
}
+ let duration = begin.elapsed().as_secs_f64();
- reports
+ IterationResult {
+ reports,
+ duration,
+ }
}
I would be interested in doing a PR on this if you think it might be worth it. We might need to discuss on how the stats on iterations should be displayed in the ouput (when --stats
is toggled).
Regards 😄