Skip to content

Commit cdeebda

Browse files
zhuqi-lucascipherstakes
authored andcommitted
Minor: add average time for clickbench benchmark query (apache#15381)
1 parent 5f1a3d0 commit cdeebda

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

benchmarks/src/clickbench.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,7 @@ impl RunOpt {
129129
self.register_hits(&ctx).await?;
130130

131131
let iterations = self.common.iterations;
132+
let mut millis = Vec::with_capacity(iterations);
132133
let mut benchmark_run = BenchmarkRun::new();
133134
for query_id in query_range {
134135
benchmark_run.start_new_case(&format!("Query {query_id}"));
@@ -140,6 +141,7 @@ impl RunOpt {
140141
let results = ctx.sql(sql).await?.collect().await?;
141142
let elapsed = start.elapsed();
142143
let ms = elapsed.as_secs_f64() * 1000.0;
144+
millis.push(ms);
143145
let row_count: usize = results.iter().map(|b| b.num_rows()).sum();
144146
println!(
145147
"Query {query_id} iteration {i} took {ms:.1} ms and returned {row_count} rows"
@@ -149,6 +151,8 @@ impl RunOpt {
149151
if self.common.debug {
150152
ctx.sql(sql).await?.explain(false, false)?.show().await?;
151153
}
154+
let avg = millis.iter().sum::<f64>() / millis.len() as f64;
155+
println!("Query {query_id} avg time: {avg:.2} ms");
152156
}
153157
benchmark_run.maybe_write_json(self.output_path.as_ref())?;
154158
Ok(())

0 commit comments

Comments
 (0)