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

Function run_native_postgres_speed_benchmark

xtask/src/main.rs:2188–2229  ·  view source on GitHub ↗
(
    client: &tokio_postgres::Client,
    sql_source: SpeedSqlSource,
    open_micros: u128,
    connect_micros: u128,
)

Source from the content-addressed store, hash-verified

2186}
2187
2188async fn run_native_postgres_speed_benchmark(
2189 client: &tokio_postgres::Client,
2190 sql_source: SpeedSqlSource,
2191 open_micros: u128,
2192 connect_micros: u128,
2193) -> Result<BenchmarkRun> {
2194 client
2195 .simple_query(
2196 "DROP TABLE IF EXISTS t1 CASCADE;\
2197 DROP TABLE IF EXISTS t2 CASCADE;\
2198 DROP TABLE IF EXISTS t2_1 CASCADE;\
2199 DROP TABLE IF EXISTS t3 CASCADE;\
2200 DROP TABLE IF EXISTS t3_1 CASCADE;",
2201 )
2202 .await
2203 .context("clear native Postgres speed benchmark tables")?;
2204
2205 let mut tests = Vec::new();
2206 for case in speed_cases(1.0, sql_source)? {
2207 let started = Instant::now();
2208 client
2209 .simple_query(&case.sql)
2210 .await
2211 .with_context(|| format!("execute native Postgres speed benchmark {}", case.id))?;
2212 tests.push(single_sample_result(
2213 case.id,
2214 case.label,
2215 "seconds",
2216 case.operation_count,
2217 started.elapsed(),
2218 ));
2219 }
2220 Ok(BenchmarkRun {
2221 suite: "speed",
2222 mode: "native_postgres",
2223 description: "Native Postgres speed suite over Unix socket using tokio-postgres simple_query.",
2224 open_micros,
2225 connect_micros: Some(connect_micros),
2226 setup_micros: 0,
2227 tests,
2228 })
2229}
2230
2231fn native_postgres_sqlx_options(native: &NativePostgres) -> PgConnectOptions {
2232 PgConnectOptions::new_without_pgpass()

Callers 1

perf_native_postgresFunction · 0.85

Calls 4

speed_casesFunction · 0.85
single_sample_resultFunction · 0.85
pushMethod · 0.80
elapsedMethod · 0.80

Tested by

no test coverage detected