MCPcopy Create free account
hub / github.com/f0rr0/oliphaunt / run_speed_server_sqlx_benchmark

Function run_speed_server_sqlx_benchmark

xtask/src/main.rs:4156–4203  ·  view source on GitHub ↗
(scale: f64, sql_source: SpeedSqlSource)

Source from the content-addressed store, hash-verified

4154}
4155
4156fn run_speed_server_sqlx_benchmark(scale: f64, sql_source: SpeedSqlSource) -> Result<BenchmarkRun> {
4157 let open_started = Instant::now();
4158 let server = benchmark_pglite_server()?;
4159 let open_micros = open_started.elapsed().as_micros();
4160 let uri = server.database_url();
4161 let runtime = tokio::runtime::Builder::new_current_thread()
4162 .enable_all()
4163 .build()
4164 .context("create benchmark Tokio runtime")?;
4165
4166 let (connect_micros, tests) = runtime.block_on(async {
4167 let connect_started = Instant::now();
4168 let mut conn = sqlx::PgConnection::connect(&uri)
4169 .await
4170 .context("connect SQLx speed benchmark client")?;
4171 let connect_micros = connect_started.elapsed().as_micros();
4172
4173 let mut tests = Vec::new();
4174 for case in speed_cases(scale, sql_source)? {
4175 let started = Instant::now();
4176 conn.execute(case.sql.as_str())
4177 .await
4178 .with_context(|| format!("execute speed benchmark {} over SQLx", case.id))?;
4179 tests.push(single_sample_result(
4180 case.id,
4181 case.label,
4182 "seconds",
4183 case.operation_count,
4184 started.elapsed(),
4185 ));
4186 }
4187 conn.close()
4188 .await
4189 .context("close SQLx speed benchmark client")?;
4190 Ok::<_, anyhow::Error>((connect_micros, tests))
4191 })?;
4192 server.shutdown()?;
4193
4194 Ok(BenchmarkRun {
4195 suite: "speed",
4196 mode: "server_sqlx",
4197 description: "Generated SQLite speedtest-style SQL suite through one SQLx connection to PgliteServer.",
4198 open_micros,
4199 connect_micros: Some(connect_micros),
4200 setup_micros: 0,
4201 tests,
4202 })
4203}
4204
4205fn benchmark_pglite_server() -> Result<PgliteServer> {
4206 PgliteServer::builder()

Callers 1

perf_benchFunction · 0.85

Calls 10

benchmark_pglite_serverFunction · 0.85
speed_casesFunction · 0.85
single_sample_resultFunction · 0.85
elapsedMethod · 0.80
database_urlMethod · 0.80
buildMethod · 0.80
executeMethod · 0.80
pushMethod · 0.80
closeMethod · 0.45
shutdownMethod · 0.45

Tested by

no test coverage detected