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

Function run_native_postgres_rtt_benchmark

xtask/src/main.rs:2144–2186  ·  view source on GitHub ↗
(
    client: &tokio_postgres::Client,
    iterations: usize,
    open_micros: u128,
    connect_micros: u128,
)

Source from the content-addressed store, hash-verified

2142}
2143
2144async fn run_native_postgres_rtt_benchmark(
2145 client: &tokio_postgres::Client,
2146 iterations: usize,
2147 open_micros: u128,
2148 connect_micros: u128,
2149) -> Result<BenchmarkRun> {
2150 let setup_started = Instant::now();
2151 client
2152 .simple_query(rtt_setup_sql())
2153 .await
2154 .context("execute native Postgres RTT setup")?;
2155 let setup_micros = setup_started.elapsed().as_micros();
2156
2157 let mut tests = Vec::new();
2158 for case in rtt_cases() {
2159 let mut samples = Vec::with_capacity(iterations);
2160 for _ in 0..iterations {
2161 let started = Instant::now();
2162 client
2163 .simple_query(&case.sql)
2164 .await
2165 .with_context(|| format!("execute native Postgres RTT benchmark {}", case.id))?;
2166 samples.push(started.elapsed().as_micros());
2167 }
2168 tests.push(samples_result(
2169 case.id,
2170 format!("Test {}: {}", case.id, case.label),
2171 "milliseconds",
2172 iterations,
2173 samples,
2174 ));
2175 }
2176
2177 Ok(BenchmarkRun {
2178 suite: "rtt",
2179 mode: "native_postgres",
2180 description: "Native Postgres over Unix socket using tokio-postgres simple_query.",
2181 open_micros,
2182 connect_micros: Some(connect_micros),
2183 setup_micros,
2184 tests,
2185 })
2186}
2187
2188async fn run_native_postgres_speed_benchmark(
2189 client: &tokio_postgres::Client,

Callers 1

perf_native_postgresFunction · 0.85

Calls 5

rtt_setup_sqlFunction · 0.85
rtt_casesFunction · 0.85
samples_resultFunction · 0.85
elapsedMethod · 0.80
pushMethod · 0.80

Tested by

no test coverage detected