mirror of
https://github.com/launchbadge/sqlx.git
synced 2025-10-24 10:05:19 +00:00
1.7 KiB
1.7 KiB
SQLx Self-Benchmarks
This Cargo project implements various benchmarks for SQLx using Criterion.
Available Benchmarks
- Group
pg_pool: benchmarkssqlx::Poolagainst a PostgreSQL server.DATABASE_URLmust be set (or in.env) pointing to a PostgreSQL server. It should preferably be running on the same machine as the benchmarks to reduce latency.- The
postgresfeature must be enabled for this benchmark to run. - Benchmarks:
bench_pgpool_acquire: benchmarksPool::acquire()when many concurrent tasks are also using the pool, with or without the pool being fair. Concurrently to the benchmark iteration function calling and blocking onPool::acquire(), a varying number of background tasks are also callingacquire()and holding the acquired connection for 500µs each before releasing it back to the pool. The pool is created with.min_connections(50).max_connections(50)so we shouldn't be measuring anything but the actual overhead ofPool's bookeeping.
Running
You must choose a runtime to execute the benchmarks on; the feature flags are the same as the sqlx crate:
cargo bench --features runtime-tokio-native-tls
cargo bench --features runtime-async-std-rustls
When complete, the benchmark results will be in target/criterion/.
Open target/criterion/report/index.html or pick one of the benchmark subfolders and open
report/index.html there to view the results.
Benchmark Results
If you want to share the results here, please follow the format below.