Benchmark | Description |
---|---|
load | tracks performance of loading "raw" data into ecto structures |
to_sql | tracks performance of parsing Ecto.Query structures into "raw" SQL query strings |
insert | tracks performance of inserting changesets and structs in the database with Repo.insert!/1 function |
For reference, these results were run with a Sabrent Rocket Q 1TB NVMe SSD.
Ecto has a benchmark suite to track performance of sensitive operations. Benchmarks are run using the Benchee library and need PostgreSQL and MySQL up and running.
To run the benchmarks tests just type in the console:
mix run bench/bench_helper.exs
Benchmarks are inside the scripts/
directory and are divided into two
categories:
-
micro benchmarks
: Operations that don't actually interface with the database, but might need it up and running to start the Ecto agents and processes. -
macro benchmarks
: Operations that are actually run in the database. This are more likely to integration tests.
You can also run a benchmark individually by giving the path to the benchmark
script instead of bench/bench_helper.exs
.
The easiest way to setup mysql and postgresql for the benchmarks is via Docker. Run the following commands to get an instance of each running.
docker run -p 3306:3306 -e MYSQL_ALLOW_EMPTY_PASSWORD=yes mysql:8
docker run -p 5432:5432 -e POSTGRES_PASSWORD=postgres postgres:13.2