(
conn: &mut sqlx::PgConnection,
iterations: usize,
open_micros: u128,
connect_micros: u128,
)
| 2359 | } |
| 2360 | |
| 2361 | async fn run_native_postgres_rtt_sqlx_benchmark( |
| 2362 | conn: &mut sqlx::PgConnection, |
| 2363 | iterations: usize, |
| 2364 | open_micros: u128, |
| 2365 | connect_micros: u128, |
| 2366 | ) -> Result<BenchmarkRun> { |
| 2367 | let setup_started = Instant::now(); |
| 2368 | conn.execute(rtt_setup_sql()) |
| 2369 | .await |
| 2370 | .context("execute native Postgres RTT setup over SQLx")?; |
| 2371 | let setup_micros = setup_started.elapsed().as_micros(); |
| 2372 | |
| 2373 | let mut tests = Vec::new(); |
| 2374 | for case in rtt_cases() { |
| 2375 | let mut samples = Vec::with_capacity(iterations); |
| 2376 | for _ in 0..iterations { |
| 2377 | let started = Instant::now(); |
| 2378 | conn.execute(case.sql.as_str()).await.with_context(|| { |
| 2379 | format!( |
| 2380 | "execute native Postgres RTT benchmark {} over SQLx", |
| 2381 | case.id |
| 2382 | ) |
| 2383 | })?; |
| 2384 | samples.push(started.elapsed().as_micros()); |
| 2385 | } |
| 2386 | tests.push(samples_result( |
| 2387 | case.id, |
| 2388 | format!("Test {}: {}", case.id, case.label), |
| 2389 | "milliseconds", |
| 2390 | iterations, |
| 2391 | samples, |
| 2392 | )); |
| 2393 | } |
| 2394 | |
| 2395 | Ok(BenchmarkRun { |
| 2396 | suite: "rtt", |
| 2397 | mode: "native_postgres_sqlx", |
| 2398 | description: "Native Postgres over TCP using one long-lived SQLx connection.", |
| 2399 | open_micros, |
| 2400 | connect_micros: Some(connect_micros), |
| 2401 | setup_micros, |
| 2402 | tests, |
| 2403 | }) |
| 2404 | } |
| 2405 | |
| 2406 | async fn run_pglite_nodefs_rtt_sqlx_benchmark( |
| 2407 | conn: &mut sqlx::PgConnection, |
no test coverage detected