MCPcopy Create free account
hub / github.com/apache/datafusion / benchmark_query

Method benchmark_query

benchmarks/src/tpcds/run.rs:196–240  ·  view source on GitHub ↗
(
        &self,
        query_id: usize,
        ctx: &SessionContext,
    )

Source from the content-addressed store, hash-verified

194 }
195
196 async fn benchmark_query(
197 &self,
198 query_id: usize,
199 ctx: &SessionContext,
200 ) -> Result<Vec<QueryResult>> {
201 let mut millis = vec![];
202 // run benchmark
203 let mut query_results = vec![];
204
205 let sql = &get_query_sql(self.query_path.to_str().unwrap(), query_id)?;
206
207 if self.common.debug {
208 println!("=== SQL for query {query_id} ===\n{}\n", sql.join(";\n"));
209 }
210
211 for i in 0..self.iterations() {
212 let start = Instant::now();
213
214 // query 15 is special, with 3 statements. the second statement is the one from which we
215 // want to capture the results
216 let mut result = vec![];
217
218 for query in sql {
219 result = self.execute_query(ctx, query).await?;
220 }
221
222 let elapsed = start.elapsed();
223 let ms = elapsed.as_secs_f64() * 1000.0;
224 millis.push(ms);
225 info!("output:\n\n{}\n\n", pretty_format_batches(&result)?);
226 let row_count = result.iter().map(|b| b.num_rows()).sum();
227 println!(
228 "Query {query_id} iteration {i} took {ms:.1} ms and returned {row_count} rows"
229 );
230 query_results.push(QueryResult { elapsed, row_count });
231 }
232
233 let avg = millis.iter().sum::<f64>() / millis.len() as f64;
234 println!("Query {query_id} avg time: {avg:.2} ms");
235
236 // Print memory stats using mimalloc (only when compiled with --features mimalloc_extended)
237 print_memory_stats();
238
239 Ok(query_results)
240 }
241
242 async fn register_tables(&self, ctx: &SessionContext) -> Result<()> {
243 for table in TPCDS_TABLES {

Callers 1

runMethod · 0.45

Calls 9

print_memory_statsFunction · 0.85
sumMethod · 0.80
get_query_sqlFunction · 0.70
iterationsMethod · 0.45
execute_queryMethod · 0.45
pushMethod · 0.45
mapMethod · 0.45
iterMethod · 0.45
lenMethod · 0.45

Tested by

no test coverage detected