(c: &mut Criterion)
| 86 | } |
| 87 | |
| 88 | pub 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| { |
nothing calls this directly
no test coverage detected