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

Function sql

benchmarks/benches/sql.rs:88–162  ·  view source on GitHub ↗
(c: &mut Criterion)

Source from the content-addressed store, hash-verified

86}
87
88pub fn sql(c: &mut Criterion) {
89 env_logger::init();
90
91 let start = Instant::now();
92 let args = EnvParser::parse();
93 let rt = make_tokio_runtime();
94
95 println!("Loading benchmarks...");
96
97 let benchmarks = rt.block_on(async {
98 let ctx = make_ctx(&args).expect("SessionContext creation failed");
99
100 load_benchmarks(&args, &ctx, &SQL_BENCHMARK_DIRECTORY)
101 .await
102 .unwrap_or_else(|err| panic!("failed load benchmarks: {err:?}"))
103 });
104
105 println!(
106 "Loaded benchmarks in {} ms ...",
107 start.elapsed().as_millis()
108 );
109
110 for (group, benchmarks) in benchmarks {
111 let mut group = c.benchmark_group(group);
112 group.sample_size(10);
113 group.sampling_mode(SamplingMode::Flat);
114
115 for mut benchmark in benchmarks {
116 // create a context
117 let ctx = make_ctx(&args).expect("SessionContext creation failed");
118
119 // initialize the benchmark. This parses the benchmark file and does any pre-execution
120 // work such as loading data into tables
121 rt.block_on(async {
122 benchmark
123 .initialize(&ctx)
124 .await
125 .expect("initialization failed");
126
127 // run assertions
128 benchmark.assert(&ctx).await.expect("assertion failed");
129 });
130
131 let mut name = benchmark.name().to_string();
132 if !benchmark.subgroup().is_empty() {
133 name.push('_');
134 name.push_str(benchmark.subgroup());
135 }
136
137 if args.persist_results {
138 handle_persist(&rt, &ctx, &name, &mut benchmark);
139 } else if args.validate {
140 handle_verify(&rt, &ctx, &name, &mut benchmark);
141 } else {
142 info!("Running benchmark {name} ...");
143
144 let name = name.clone();
145 group.bench_function(name.clone(), |b| {

Callers

nothing calls this directly

Calls 15

make_tokio_runtimeFunction · 0.85
make_ctxFunction · 0.85
load_benchmarksFunction · 0.85
handle_persistFunction · 0.85
handle_verifyFunction · 0.85
handle_runFunction · 0.85
print_memory_statsFunction · 0.85
initializeMethod · 0.80
subgroupMethod · 0.80
cleanupMethod · 0.80
initFunction · 0.50
assertMethod · 0.45

Tested by

no test coverage detected