From af2369c79c4f497982317ba4f7fbd0306e23887b Mon Sep 17 00:00:00 2001 From: Kevin Lang Date: Tue, 23 Mar 2021 22:10:55 -0400 Subject: [PATCH 1/3] update benchmarks, run all but the all one and check in results --- README.md | 6 + bench/README.md | 19 +- bench/results/insert.md | 204 ++++++++ bench/results/load.md | 508 ++++++++++++++++++ bench/results/to_sql.md | 736 +++++++++++++++++++++++++++ bench/scripts/macro/all_bench.exs | 13 +- bench/scripts/macro/insert_bench.exs | 12 +- bench/scripts/micro/load_bench.exs | 15 +- bench/scripts/micro/to_sql_bench.exs | 9 +- bench/support/repo.exs | 10 +- bench/support/setup.exs | 12 +- mix.exs | 6 +- mix.lock | 9 +- 13 files changed, 1520 insertions(+), 39 deletions(-) create mode 100644 bench/results/insert.md create mode 100644 bench/results/load.md create mode 100644 bench/results/to_sql.md diff --git a/README.md b/README.md index a62e0fa..04e27f7 100644 --- a/README.md +++ b/README.md @@ -39,3 +39,9 @@ config :my_app, config :my_app, MyApp.Repo, database: "path/to/my/database.db", ``` + +## Benchmarks + +We have some benchmarks comparing it against the `MySQL` and `Postgres` adapters. + +You can read more about those at [bench/README.md](bench/README.md). diff --git a/bench/README.md b/bench/README.md index 6f0d5ee..28fbb40 100644 --- a/bench/README.md +++ b/bench/README.md @@ -1,5 +1,17 @@ # Ecto Benchmarks +## Results + +| Benchmark | Description | +| --------- | ------------ | +| [load](results/load.md) | tracks performance of loading "raw" data into ecto structures | +| [to_sql](results/to_sql.md) | tracks performance of parsing `Ecto.Query` structures into "raw" SQL query strings | +| [insert](results/insert.md) | 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. + +## Running the benchmarks + Ecto has a benchmark suite to track performance of sensitive operations. Benchmarks are run using the [Benchee](https://github.com/PragTob/benchee) library and need PostgreSQL and MySQL up and running. @@ -28,9 +40,10 @@ 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`. -# Docker -I had Postgres already installed and running locally, but needed to get MySQL up and running. The easiest way to do this is with this command: +### Docker +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 --name mysql_server -e MYSQL_ALLOW_EMPTY_PASSWORD=yes mysql:5.7 +docker run -p 3306:3306 -e MYSQL_ALLOW_EMPTY_PASSWORD=yes mysql:5.7 +docker run -p 5432:5432 -e POSTGRES_PASSWORD=postgres postgres:13.2 ``` diff --git a/bench/results/insert.md b/bench/results/insert.md new file mode 100644 index 0000000..3e8b360 --- /dev/null +++ b/bench/results/insert.md @@ -0,0 +1,204 @@ + +# Benchmark + +Benchmark run from 2021-03-24 02:05:58.706995Z UTC + +## System + +Benchmark suite executing on the following system: + + + + + + + + + + + + + + + + + + + + + +
Operating SystemLinux
CPU InformationAMD Ryzen 7 PRO 4750U with Radeon Graphics
Number of Available Cores16
Available Memory14.92 GB
Elixir Version1.11.3
Erlang Version23.2.6
+ +## Configuration + +Benchmark suite executing with the following configuration: + + + + + + + + + + + + +
:time5 s
:parallel1
:warmup2 s
+ +## Statistics + + + + +__Input: Changeset__ + +Run Time + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameIPSAverageDevitationMedian99th %
SQLite3 Insert7218.070.139 ms±43.60%0.123 ms0.37 ms
Pg Insert421.572.37 ms±12.13%2.37 ms2.90 ms
MyXQL Insert284.253.52 ms±13.34%3.53 ms5.05 ms
+ + +Comparison + + + + + + + + + + + + + + + + + + + + + + + + +
NameIPSSlower
SQLite3 Insert7218.07 
Pg Insert421.5717.12x
MyXQL Insert284.2525.39x
+ + + +
+ + +__Input: Struct__ + +Run Time + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameIPSAverageDevitationMedian99th %
SQLite3 Insert7765.760.129 ms±32.88%0.122 ms0.28 ms
Pg Insert422.862.36 ms±10.49%2.36 ms3.02 ms
MyXQL Insert274.003.65 ms±38.43%3.59 ms4.75 ms
+ + +Comparison + + + + + + + + + + + + + + + + + + + + + + + + +
NameIPSSlower
SQLite3 Insert7765.76 
Pg Insert422.8618.37x
MyXQL Insert274.0028.34x
+ + + +
+ diff --git a/bench/results/load.md b/bench/results/load.md new file mode 100644 index 0000000..ec27e51 --- /dev/null +++ b/bench/results/load.md @@ -0,0 +1,508 @@ + +# Benchmark + +Benchmark run from 2021-03-24 01:58:24.995583Z UTC + +## System + +Benchmark suite executing on the following system: + + + + + + + + + + + + + + + + + + + + + +
Operating SystemLinux
CPU InformationAMD Ryzen 7 PRO 4750U with Radeon Graphics
Number of Available Cores16
Available Memory14.92 GB
Elixir Version1.11.3
Erlang Version23.2.6
+ +## Configuration + +Benchmark suite executing with the following configuration: + + + + + + + + + + + + +
:time5 s
:parallel1
:warmup2 s
+ +## Statistics + + + + +__Input: Big 1 Million__ + +Run Time + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameIPSAverageDevitationMedian99th %
SQLite3 Loader0.352.82 s±15.78%2.82 s3.13 s
Pg Loader0.342.92 s±17.97%2.92 s3.29 s
MyXQL Loader0.332.99 s±13.08%2.99 s3.26 s
+ + +Comparison + + + + + + + + + + + + + + + + + + + + + + + + +
NameIPSSlower
SQLite3 Loader0.35 
Pg Loader0.341.04x
MyXQL Loader0.331.06x
+ + + +
+ + +__Input: Date attr__ + +Run Time + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameIPSAverageDevitationMedian99th %
Pg Loader4.61217.08 ms±13.97%214.42 ms271.56 ms
MyXQL Loader4.56219.25 ms±18.19%210.43 ms300.02 ms
SQLite3 Loader4.49222.95 ms±15.03%232.42 ms266.39 ms
+ + +Comparison + + + + + + + + + + + + + + + + + + + + + + + + +
NameIPSSlower
Pg Loader4.61 
MyXQL Loader4.561.01x
SQLite3 Loader4.491.03x
+ + + +
+ + +__Input: Medium 100 Thousand__ + +Run Time + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameIPSAverageDevitationMedian99th %
MyXQL Loader4.53220.75 ms±15.57%209.17 ms287.22 ms
Pg Loader4.40227.35 ms±16.30%222.39 ms335.90 ms
SQLite3 Loader4.35230.09 ms±19.61%236.94 ms309.96 ms
+ + +Comparison + + + + + + + + + + + + + + + + + + + + + + + + +
NameIPSSlower
MyXQL Loader4.53 
Pg Loader4.401.03x
SQLite3 Loader4.351.04x
+ + + +
+ + +__Input: Small 1 Thousand__ + +Run Time + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameIPSAverageDevitationMedian99th %
Pg Loader883.241.13 ms±62.88%0.93 ms2.71 ms
SQLite3 Loader873.531.14 ms±60.06%0.92 ms2.90 ms
MyXQL Loader862.331.16 ms±62.27%0.92 ms2.77 ms
+ + +Comparison + + + + + + + + + + + + + + + + + + + + + + + + +
NameIPSSlower
Pg Loader883.24 
SQLite3 Loader873.531.01x
MyXQL Loader862.331.02x
+ + + +
+ + +__Input: Time attr__ + +Run Time + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameIPSAverageDevitationMedian99th %
SQLite3 Loader3.40294.30 ms±15.60%281.23 ms367.65 ms
MyXQL Loader3.18314.55 ms±17.11%313.35 ms415.89 ms
Pg Loader3.03329.99 ms±16.46%321.68 ms457.42 ms
+ + +Comparison + + + + + + + + + + + + + + + + + + + + + + + + +
NameIPSSlower
SQLite3 Loader3.40 
MyXQL Loader3.181.07x
Pg Loader3.031.12x
+ + + +
+ + +__Input: UUID attr__ + +Run Time + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameIPSAverageDevitationMedian99th %
SQLite3 Loader3.61277.20 ms±16.59%266.05 ms372.08 ms
Pg Loader2.75363.06 ms±14.14%382.70 ms437.37 ms
MyXQL Loader2.73365.91 ms±19.81%367.23 ms515.29 ms
+ + +Comparison + + + + + + + + + + + + + + + + + + + + + + + + +
NameIPSSlower
SQLite3 Loader3.61 
Pg Loader2.751.31x
MyXQL Loader2.731.32x
+ + + +
+ diff --git a/bench/results/to_sql.md b/bench/results/to_sql.md new file mode 100644 index 0000000..c20b658 --- /dev/null +++ b/bench/results/to_sql.md @@ -0,0 +1,736 @@ + +# Benchmark + +Benchmark run from 2021-03-24 02:02:16.278354Z UTC + +## System + +Benchmark suite executing on the following system: + + + + + + + + + + + + + + + + + + + + + +
Operating SystemLinux
CPU InformationAMD Ryzen 7 PRO 4750U with Radeon Graphics
Number of Available Cores16
Available Memory14.92 GB
Elixir Version1.11.3
Erlang Version23.2.6
+ +## Configuration + +Benchmark suite executing with the following configuration: + + + + + + + + + + + + +
:time5 s
:parallel1
:warmup2 s
+ +## Statistics + + + + +__Input: Complex Query 2 Joins__ + +Run Time + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameIPSAverageDevitationMedian99th %
MyXQL Query Builder105.28 K9.50 μs±116.92%8.66 μs24.79 μs
Pg Query Builder96.97 K10.31 μs±220.90%8.66 μs26.75 μs
SQLite3 Query Builder90.46 K11.05 μs±204.34%8.66 μs39.53 μs
+ + +Comparison + + + + + + + + + + + + + + + + + + + + + + + + +
NameIPSSlower
MyXQL Query Builder105.28 K 
Pg Query Builder96.97 K1.09x
SQLite3 Query Builder90.46 K1.16x
+ + + +
+ + +__Input: Complex Query 4 Joins__ + +Run Time + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameIPSAverageDevitationMedian99th %
Pg Query Builder100.25 K9.97 μs±92.25%9.15 μs23.68 μs
MyXQL Query Builder98.47 K10.16 μs±88.64%9.22 μs28.70 μs
SQLite3 Query Builder90.40 K11.06 μs±117.48%9.22 μs38.69 μs
+ + +Comparison + + + + + + + + + + + + + + + + + + + + + + + + +
NameIPSSlower
Pg Query Builder100.25 K 
MyXQL Query Builder98.47 K1.02x
SQLite3 Query Builder90.40 K1.11x
+ + + +
+ + +__Input: Fetch First Registry__ + +Run Time + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameIPSAverageDevitationMedian99th %
Pg Query Builder173.31 K5.77 μs±389.85%4.47 μs20.18 μs
MyXQL Query Builder173.06 K5.78 μs±411.02%4.82 μs16.20 μs
SQLite3 Query Builder167.17 K5.98 μs±420.59%4.82 μs19.42 μs
+ + +Comparison + + + + + + + + + + + + + + + + + + + + + + + + +
NameIPSSlower
Pg Query Builder173.31 K 
MyXQL Query Builder173.06 K1.0x
SQLite3 Query Builder167.17 K1.04x
+ + + +
+ + +__Input: Fetch Last Registry__ + +Run Time + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameIPSAverageDevitationMedian99th %
Pg Query Builder177.36 K5.64 μs±446.37%4.47 μs17.67 μs
SQLite3 Query Builder169.74 K5.89 μs±394.73%4.82 μs18.16 μs
MyXQL Query Builder162.83 K6.14 μs±383.32%4.82 μs22.14 μs
+ + +Comparison + + + + + + + + + + + + + + + + + + + + + + + + +
NameIPSSlower
Pg Query Builder177.36 K 
SQLite3 Query Builder169.74 K1.04x
MyXQL Query Builder162.83 K1.09x
+ + + +
+ + +__Input: Ordinary Delete All__ + +Run Time + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameIPSAverageDevitationMedian99th %
Pg Query Builder335.81 K2.98 μs±775.40%2.03 μs9.43 μs
SQLite3 Query Builder325.92 K3.07 μs±948.36%2.02 μs8.31 μs
MyXQL Query Builder301.67 K3.31 μs±832.06%2.03 μs11.59 μs
+ + +Comparison + + + + + + + + + + + + + + + + + + + + + + + + +
NameIPSSlower
Pg Query Builder335.81 K 
SQLite3 Query Builder325.92 K1.03x
MyXQL Query Builder301.67 K1.11x
+ + + +
+ + +__Input: Ordinary Order By__ + +Run Time + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameIPSAverageDevitationMedian99th %
Pg Query Builder186.48 K5.36 μs±400.39%4.40 μs17.81 μs
MyXQL Query Builder182.02 K5.49 μs±402.64%4.40 μs17.39 μs
SQLite3 Query Builder172.19 K5.81 μs±427.38%4.47 μs21.44 μs
+ + +Comparison + + + + + + + + + + + + + + + + + + + + + + + + +
NameIPSSlower
Pg Query Builder186.48 K 
MyXQL Query Builder182.02 K1.02x
SQLite3 Query Builder172.19 K1.08x
+ + + +
+ + +__Input: Ordinary Select All__ + +Run Time + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameIPSAverageDevitationMedian99th %
Pg Query Builder200.19 K5.00 μs±657.77%3.49 μs14.88 μs
SQLite3 Query Builder199.77 K5.01 μs±698.35%3.49 μs13.90 μs
MyXQL Query Builder191.70 K5.22 μs±601.95%3.56 μs16.06 μs
+ + +Comparison + + + + + + + + + + + + + + + + + + + + + + + + +
NameIPSSlower
Pg Query Builder200.19 K 
SQLite3 Query Builder199.77 K1.0x
MyXQL Query Builder191.70 K1.04x
+ + + +
+ + +__Input: Ordinary Update All__ + +Run Time + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameIPSAverageDevitationMedian99th %
SQLite3 Query Builder263.35 K3.80 μs±1304.70%2.86 μs10.13 μs
MyXQL Query Builder260.96 K3.83 μs±760.59%2.86 μs10.20 μs
Pg Query Builder249.05 K4.02 μs±827.04%2.86 μs12.99 μs
+ + +Comparison + + + + + + + + + + + + + + + + + + + + + + + + +
NameIPSSlower
SQLite3 Query Builder263.35 K 
MyXQL Query Builder260.96 K1.01x
Pg Query Builder249.05 K1.06x
+ + + +
+ + +__Input: Ordinary Where__ + +Run Time + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameIPSAverageDevitationMedian99th %
MyXQL Query Builder162.26 K6.16 μs±343.86%5.31 μs17.74 μs
SQLite3 Query Builder159.31 K6.28 μs±305.50%5.38 μs19.35 μs
Pg Query Builder154.28 K6.48 μs±355.38%5.45 μs20.04 μs
+ + +Comparison + + + + + + + + + + + + + + + + + + + + + + + + +
NameIPSSlower
MyXQL Query Builder162.26 K 
SQLite3 Query Builder159.31 K1.02x
Pg Query Builder154.28 K1.05x
+ + + +
+ diff --git a/bench/scripts/macro/all_bench.exs b/bench/scripts/macro/all_bench.exs index 2de6e3c..cb711b1 100644 --- a/bench/scripts/macro/all_bench.exs +++ b/bench/scripts/macro/all_bench.exs @@ -20,28 +20,32 @@ Code.require_file("../../support/setup.exs", __DIR__) alias Ecto.Bench.User -limit = 5_000 +limit = 1_000 users = 1..limit |> Enum.map(fn _ -> User.sample_data() end) # We need to insert data to fetch +Ecto.Bench.SQLite3Repo.insert_all(User, users) Ecto.Bench.PgRepo.insert_all(User, users) Ecto.Bench.MyXQLRepo.insert_all(User, users) jobs = %{ + "SQLite3 Repo.all/2" => fn -> Ecto.Bench.SQLite3Repo.all(User, limit: limit) end, "Pg Repo.all/2" => fn -> Ecto.Bench.PgRepo.all(User, limit: limit) end, "MyXQL Repo.all/2" => fn -> Ecto.Bench.MyXQLRepo.all(User, limit: limit) end } path = System.get_env("BENCHMARKS_OUTPUT_PATH") || "bench/results" -file = Path.join(path, "all.json") Benchee.run( jobs, - formatters: [Benchee.Formatters.JSON, Benchee.Formatters.Console], - formatter_options: [json: [file: file]], + formatters: [ + Benchee.Formatters.Console, + {Benchee.Formatters.Markdown, + file: Path.join(path, "all.md")} + ], time: 10, after_each: fn results -> ^limit = length(results) @@ -49,5 +53,6 @@ Benchee.run( ) # Clean inserted data +Ecto.Bench.SQLite3Repo.delete_all(User) Ecto.Bench.PgRepo.delete_all(User) Ecto.Bench.MyXQLRepo.delete_all(User) diff --git a/bench/scripts/macro/insert_bench.exs b/bench/scripts/macro/insert_bench.exs index 8181a7a..976cd76 100644 --- a/bench/scripts/macro/insert_bench.exs +++ b/bench/scripts/macro/insert_bench.exs @@ -25,22 +25,24 @@ inputs = %{ } jobs = %{ - "Exqlite Insert" => fn entry -> Ecto.Bench.ExqliteRepo.insert!(entry) end, + "SQLite3 Insert" => fn entry -> Ecto.Bench.SQLite3Repo.insert!(entry) end, "Pg Insert" => fn entry -> Ecto.Bench.PgRepo.insert!(entry) end, "MyXQL Insert" => fn entry -> Ecto.Bench.MyXQLRepo.insert!(entry) end } path = System.get_env("BENCHMARKS_OUTPUT_PATH") || "bench/results" -file = Path.join(path, "insert.json") Benchee.run( jobs, inputs: inputs, - formatters: [Benchee.Formatters.JSON, Benchee.Formatters.Console], - formatter_options: [json: [file: file]] + formatters: [ + Benchee.Formatters.Console, + {Benchee.Formatters.Markdown, + file: Path.join(path, "insert.md")} + ] ) # Clean inserted data -Ecto.Bench.ExqliteRepo.delete_all(User) +Ecto.Bench.SQLite3Repo.delete_all(User) Ecto.Bench.PgRepo.delete_all(User) Ecto.Bench.MyXQLRepo.delete_all(User) diff --git a/bench/scripts/micro/load_bench.exs b/bench/scripts/micro/load_bench.exs index 6263551..aad4b57 100644 --- a/bench/scripts/micro/load_bench.exs +++ b/bench/scripts/micro/load_bench.exs @@ -31,25 +31,28 @@ inputs = %{ "Time attr" => 1..100_000 |> Enum.map(fn _ -> %{name: "Alice", time_attr: ~T[21:25:04.361140]} end), "Date attr" => 1..100_000 |> Enum.map(fn _ -> %{name: "Alice", date_attr: ~D[2018-06-20]} end), - "NaiveDateTime attr" => - 1..100_000 - |> Enum.map(fn _ -> %{name: "Alice", naive_datetime_attr: ~N[2019-06-20 21:32:07.424178]} end), + # "NaiveDateTime attr" => + # 1..100_000 + # |> Enum.map(fn _ -> %{name: "Alice", naive_datetime_attr: ~N[2019-06-20 21:32:07.424178]} end), "UUID attr" => 1..100_000 |> Enum.map(fn _ -> %{name: "Alice", uuid: Ecto.UUID.bingenerate()} end) } jobs = %{ + "SQLite3 Loader" => fn data -> Enum.map(data, &Ecto.Bench.SQLite3Repo.load(User, &1)) end, "Pg Loader" => fn data -> Enum.map(data, &Ecto.Bench.PgRepo.load(User, &1)) end, "MyXQL Loader" => fn data -> Enum.map(data, &Ecto.Bench.MyXQLRepo.load(User, &1)) end } path = System.get_env("BENCHMARKS_OUTPUT_PATH") || "bench/results" -file = Path.join(path, "load.json") Benchee.run( jobs, inputs: inputs, - formatters: [Benchee.Formatters.JSON, Benchee.Formatters.Console], - formatter_options: [json: [file: file]] + formatters: [ + Benchee.Formatters.Console, + {Benchee.Formatters.Markdown, + file: Path.join(path, "load.md")} + ] ) diff --git a/bench/scripts/micro/to_sql_bench.exs b/bench/scripts/micro/to_sql_bench.exs index 138750f..5a16a18 100644 --- a/bench/scripts/micro/to_sql_bench.exs +++ b/bench/scripts/micro/to_sql_bench.exs @@ -49,16 +49,19 @@ inputs = %{ } jobs = %{ + "SQLite3 Query Builder" => fn {type, query} -> Ecto.Bench.SQLite3Repo.to_sql(type, query) end, "Pg Query Builder" => fn {type, query} -> Ecto.Bench.PgRepo.to_sql(type, query) end, "MyXQL Query Builder" => fn {type, query} -> Ecto.Bench.MyXQLRepo.to_sql(type, query) end } path = System.get_env("BENCHMARKS_OUTPUT_PATH") || "bench/results" -file = Path.join(path, "to_sql.json") Benchee.run( jobs, inputs: inputs, - formatters: [Benchee.Formatters.JSON, Benchee.Formatters.Console], - formatter_options: [json: [file: file]] + formatters: [ + Benchee.Formatters.Console, + {Benchee.Formatters.Markdown, + file: Path.join(path, "to_sql.md")} + ] ) diff --git a/bench/support/repo.exs b/bench/support/repo.exs index 0322a01..bd9ae61 100644 --- a/bench/support/repo.exs +++ b/bench/support/repo.exs @@ -20,9 +20,9 @@ Application.put_env( Application.put_env( :ecto_sql, - Ecto.Bench.ExqliteRepo, - adapter: Ecto.Adapters.Exqlite, - database: "/tmp/exqlite_bench.db", + Ecto.Bench.SQLite3Repo, + adapter: Ecto.Adapters.SQLite3, + database: "/tmp/SQLite3_bench.db", journal_mode: :wal, cache_size: -64000, temp_store: :memory, @@ -38,6 +38,6 @@ defmodule Ecto.Bench.MyXQLRepo do use Ecto.Repo, otp_app: :ecto_sql, adapter: Ecto.Adapters.MyXQL, log: false end -defmodule Ecto.Bench.ExqliteRepo do - use Ecto.Repo, otp_app: :ecto_sql, adapter: Ecto.Adapters.Exqlite, log: false +defmodule Ecto.Bench.SQLite3Repo do + use Ecto.Repo, otp_app: :ecto_sql, adapter: Ecto.Adapters.SQLite3, log: false end diff --git a/bench/support/setup.exs b/bench/support/setup.exs index 90eb19b..42f4de1 100644 --- a/bench/support/setup.exs +++ b/bench/support/setup.exs @@ -2,11 +2,11 @@ Code.require_file("repo.exs", __DIR__) Code.require_file("migrations.exs", __DIR__) Code.require_file("schemas.exs", __DIR__) -alias Ecto.Bench.{PgRepo, MyXQLRepo, ExqliteRepo, CreateUser} +alias Ecto.Bench.{PgRepo, MyXQLRepo, SQLite3Repo, CreateUser} {:ok, _} = Ecto.Adapters.Postgres.ensure_all_started(PgRepo.config(), :temporary) {:ok, _} = Ecto.Adapters.MyXQL.ensure_all_started(MyXQLRepo.config(), :temporary) -{:ok, _} = Ecto.Adapters.Exqlite.ensure_all_started(ExqliteRepo.config(), :temporary) +{:ok, _} = Ecto.Adapters.SQLite3.ensure_all_started(SQLite3Repo.config(), :temporary) _ = Ecto.Adapters.Postgres.storage_down(PgRepo.config()) :ok = Ecto.Adapters.Postgres.storage_up(PgRepo.config()) @@ -14,13 +14,13 @@ _ = Ecto.Adapters.Postgres.storage_down(PgRepo.config()) _ = Ecto.Adapters.MyXQL.storage_down(MyXQLRepo.config()) :ok = Ecto.Adapters.MyXQL.storage_up(MyXQLRepo.config()) -_ = Ecto.Adapters.Exqlite.storage_down(ExqliteRepo.config()) -:ok = Ecto.Adapters.Exqlite.storage_up(ExqliteRepo.config()) +_ = Ecto.Adapters.SQLite3.storage_down(SQLite3Repo.config()) +:ok = Ecto.Adapters.SQLite3.storage_up(SQLite3Repo.config()) {:ok, _pid} = PgRepo.start_link(log: false) {:ok, _pid} = MyXQLRepo.start_link(log: false) -{:ok, _pid} = ExqliteRepo.start_link(log: false) +{:ok, _pid} = SQLite3Repo.start_link(log: false) :ok = Ecto.Migrator.up(PgRepo, 0, CreateUser, log: false) :ok = Ecto.Migrator.up(MyXQLRepo, 0, CreateUser, log: false) -:ok = Ecto.Migrator.up(ExqliteRepo, 0, CreateUser, log: false) +:ok = Ecto.Migrator.up(SQLite3Repo, 0, CreateUser, log: false) diff --git a/mix.exs b/mix.exs index b656e33..2923605 100644 --- a/mix.exs +++ b/mix.exs @@ -36,12 +36,12 @@ defmodule EctoSQLite3.MixProject do {:ecto, "~> 3.5"}, {:exqlite, "~> 0.5"}, {:ex_doc, "~> 0.23.0", only: [:dev], runtime: false}, - {:jason, ">= 0.0.0", only: [:test, :docs]}, + {:jason, ">= 0.0.0", only: [:bench, :test, :docs]}, {:temp, "~> 0.4", only: [:test]}, # Benchmarks - {:benchee, "~> 0.11.0", only: :bench}, - {:benchee_json, "~> 0.4.0", only: :bench}, + {:benchee, "~> 1.0", only: :bench}, + {:benchee_markdown, "~> 0.2", only: :bench}, {:postgrex, "~> 0.15.0", only: :bench}, {:myxql, "~> 0.4.0", only: :bench} ] diff --git a/mix.lock b/mix.lock index 33de0f6..48c6ca4 100644 --- a/mix.lock +++ b/mix.lock @@ -1,10 +1,12 @@ %{ - "benchee": {:hex, :benchee, "0.11.0", "cf96e328ff5d69838dd89c21a9db22716bfcc6ef772e9d9dddf7ba622102722d", [:mix], [{:deep_merge, "~> 0.1", [hex: :deep_merge, repo: "hexpm", optional: false]}], "hexpm", "c345e090e0a61bf33e0385aa3ad394fcb7d863e313bc3fca522e390c7f39166e"}, - "benchee_json": {:hex, :benchee_json, "0.4.0", "59d3277829bd1dca8373cdb20b916cb435c2647be235d09963fc0959db908c36", [:mix], [{:benchee, "~> 0.10", [hex: :benchee, repo: "hexpm", optional: false]}, {:poison, ">= 1.4.0", [hex: :poison, repo: "hexpm", optional: false]}], "hexpm", "71a3edb6a30708de2a01368aa8f288e1c0ed7897b125adc396ce7c2c7245b1e7"}, + "benchee": {:hex, :benchee, "1.0.1", "66b211f9bfd84bd97e6d1beaddf8fc2312aaabe192f776e8931cb0c16f53a521", [:mix], [{:deep_merge, "~> 1.0", [hex: :deep_merge, repo: "hexpm", optional: false]}], "hexpm", "3ad58ae787e9c7c94dd7ceda3b587ec2c64604563e049b2a0e8baafae832addb"}, + "benchee_html": {:hex, :benchee_html, "1.0.0", "5b4d24effebd060f466fb460ec06576e7b34a00fc26b234fe4f12c4f05c95947", [:mix], [{:benchee, ">= 0.99.0 and < 2.0.0", [hex: :benchee, repo: "hexpm", optional: false]}, {:benchee_json, "~> 1.0", [hex: :benchee_json, repo: "hexpm", optional: false]}], "hexpm", "5280af9aac432ff5ca4216d03e8a93f32209510e925b60e7f27c33796f69e699"}, + "benchee_json": {:hex, :benchee_json, "1.0.0", "cc661f4454d5995c08fe10dd1f2f72f229c8f0fb1c96f6b327a8c8fc96a91fe5", [:mix], [{:benchee, ">= 0.99.0 and < 2.0.0", [hex: :benchee, repo: "hexpm", optional: false]}, {:jason, "~> 1.0", [hex: :jason, repo: "hexpm", optional: false]}], "hexpm", "da05d813f9123505f870344d68fb7c86a4f0f9074df7d7b7e2bb011a63ec231c"}, + "benchee_markdown": {:hex, :benchee_markdown, "0.2.6", "52fe95c8a4a744e5127264c3cb72db70f2adcc05113139e0a0b69b4df9e95ada", [:mix], [{:benchee, ">= 0.99.0 and < 2.0.0", [hex: :benchee, repo: "hexpm", optional: false]}], "hexpm", "0c2cb871befab33ab79ab204391400983c3a3aad55a3c0e2f0aac31a8b445ca4"}, "connection": {:hex, :connection, "1.1.0", "ff2a49c4b75b6fb3e674bfc5536451607270aac754ffd1bdfe175abe4a6d7a68", [:mix], [], "hexpm", "722c1eb0a418fbe91ba7bd59a47e28008a189d47e37e0e7bb85585a016b2869c"}, "db_connection": {:hex, :db_connection, "2.3.1", "4c9f3ed1ef37471cbdd2762d6655be11e38193904d9c5c1c9389f1b891a3088e", [:mix], [{:connection, "~> 1.0", [hex: :connection, repo: "hexpm", optional: false]}], "hexpm", "abaab61780dde30301d840417890bd9f74131041afd02174cf4e10635b3a63f5"}, "decimal": {:hex, :decimal, "2.0.0", "a78296e617b0f5dd4c6caf57c714431347912ffb1d0842e998e9792b5642d697", [:mix], [], "hexpm", "34666e9c55dea81013e77d9d87370fe6cb6291d1ef32f46a1600230b1d44f577"}, - "deep_merge": {:hex, :deep_merge, "0.2.0", "c1050fa2edf4848b9f556fba1b75afc66608a4219659e3311d9c9427b5b680b3", [:mix], [], "hexpm", "e3bf435a54ed27b0ba3a01eb117ae017988804e136edcbe8a6a14c310daa966e"}, + "deep_merge": {:hex, :deep_merge, "1.0.0", "b4aa1a0d1acac393bdf38b2291af38cb1d4a52806cf7a4906f718e1feb5ee961", [:mix], [], "hexpm", "ce708e5f094b9cd4e8f2be4f00d2f4250c4095be93f8cd6d018c753894885430"}, "earmark_parser": {:hex, :earmark_parser, "1.4.12", "b245e875ec0a311a342320da0551da407d9d2b65d98f7a9597ae078615af3449", [:mix], [], "hexpm", "711e2cc4d64abb7d566d43f54b78f7dc129308a63bc103fbd88550d2174b3160"}, "ecto": {:hex, :ecto, "3.5.8", "8ebf12be6016cb99313348ba7bb4612f4114b9a506d6da79a2adc7ef449340bc", [:mix], [{:decimal, "~> 1.6 or ~> 2.0", [hex: :decimal, repo: "hexpm", optional: false]}, {:jason, "~> 1.0", [hex: :jason, repo: "hexpm", optional: true]}, {:telemetry, "~> 0.4", [hex: :telemetry, repo: "hexpm", optional: false]}], "hexpm", "ea0be182ea8922eb7742e3ae8e71b67ee00ae177de1bf76210299a5f16ba4c77"}, "ecto_sql": {:hex, :ecto_sql, "3.5.4", "a9e292c40bd79fff88885f95f1ecd7b2516e09aa99c7dd0201aa84c54d2358e4", [:mix], [{:db_connection, "~> 2.2", [hex: :db_connection, repo: "hexpm", optional: false]}, {:ecto, "~> 3.5.0", [hex: :ecto, repo: "hexpm", optional: false]}, {:myxql, "~> 0.3.0 or ~> 0.4.0", [hex: :myxql, repo: "hexpm", optional: true]}, {:postgrex, "~> 0.15.0 or ~> 1.0", [hex: :postgrex, repo: "hexpm", optional: true]}, {:tds, "~> 2.1.1", [hex: :tds, repo: "hexpm", optional: true]}, {:telemetry, "~> 0.4.0", [hex: :telemetry, repo: "hexpm", optional: false]}], "hexpm", "1fff1a28a898d7bbef263f1f3ea425b04ba9f33816d843238c84eff883347343"}, @@ -16,7 +18,6 @@ "makeup_elixir": {:hex, :makeup_elixir, "0.15.1", "b5888c880d17d1cc3e598f05cdb5b5a91b7b17ac4eaf5f297cb697663a1094dd", [:mix], [{:makeup, "~> 1.0", [hex: :makeup, repo: "hexpm", optional: false]}, {:nimble_parsec, "~> 1.1", [hex: :nimble_parsec, repo: "hexpm", optional: false]}], "hexpm", "db68c173234b07ab2a07f645a5acdc117b9f99d69ebf521821d89690ae6c6ec8"}, "myxql": {:hex, :myxql, "0.4.5", "49784e6a3e4fc33088cc9004948ef255ee698b0d7b533fb1fa453cc99a3f9972", [:mix], [{:db_connection, "~> 2.0", [hex: :db_connection, repo: "hexpm", optional: false]}, {:decimal, "~> 1.6 or ~> 2.0", [hex: :decimal, repo: "hexpm", optional: false]}, {:geo, "~> 3.3", [hex: :geo, repo: "hexpm", optional: true]}, {:jason, "~> 1.0", [hex: :jason, repo: "hexpm", optional: true]}], "hexpm", "40a6166ab0a54f44a6e2c437aed6360ce51ce7f779557ae30d1cc4c4b4e7ad13"}, "nimble_parsec": {:hex, :nimble_parsec, "1.1.0", "3a6fca1550363552e54c216debb6a9e95bd8d32348938e13de5eda962c0d7f89", [:mix], [], "hexpm", "08eb32d66b706e913ff748f11694b17981c0b04a33ef470e33e11b3d3ac8f54b"}, - "poison": {:hex, :poison, "4.0.1", "bcb755a16fac91cad79bfe9fc3585bb07b9331e50cfe3420a24bcc2d735709ae", [:mix], [], "hexpm", "ba8836feea4b394bb718a161fc59a288fe0109b5006d6bdf97b6badfcf6f0f25"}, "postgrex": {:hex, :postgrex, "0.15.8", "f5e782bbe5e8fa178d5e3cd1999c857dc48eda95f0a4d7f7bd92a50e84a0d491", [:mix], [{:connection, "~> 1.0", [hex: :connection, repo: "hexpm", optional: false]}, {:db_connection, "~> 2.1", [hex: :db_connection, repo: "hexpm", optional: false]}, {:decimal, "~> 1.5 or ~> 2.0", [hex: :decimal, repo: "hexpm", optional: false]}, {:jason, "~> 1.0", [hex: :jason, repo: "hexpm", optional: true]}], "hexpm", "698fbfacea34c4cf22c8281abeb5cf68d99628d541874f085520ab3b53d356fe"}, "telemetry": {:hex, :telemetry, "0.4.2", "2808c992455e08d6177322f14d3bdb6b625fbcfd233a73505870d8738a2f4599", [:rebar3], [], "hexpm", "2d1419bd9dda6a206d7b5852179511722e2b18812310d304620c7bd92a13fcef"}, "temp": {:hex, :temp, "0.4.7", "2c78482cc2294020a4bc0c95950b907ff386523367d4e63308a252feffbea9f2", [:mix], [], "hexpm", "6af19e7d6a85a427478be1021574d1ae2a1e1b90882586f06bde76c63cd03e0d"}, From 1ac9ab96655fd8ee8fa4ac9fbf622d4820142c6d Mon Sep 17 00:00:00 2001 From: Kevin Lang Date: Tue, 23 Mar 2021 22:11:21 -0400 Subject: [PATCH 2/3] format --- .formatter.exs | 2 +- bench/scripts/macro/all_bench.exs | 3 +-- bench/scripts/macro/insert_bench.exs | 3 +-- bench/scripts/micro/load_bench.exs | 10 ++++++---- bench/scripts/micro/to_sql_bench.exs | 11 +++++++---- 5 files changed, 16 insertions(+), 13 deletions(-) diff --git a/.formatter.exs b/.formatter.exs index 56bf94c..fcf1fd0 100644 --- a/.formatter.exs +++ b/.formatter.exs @@ -2,7 +2,7 @@ [ inputs: [ "{mix,.formatter}.exs", - "{lib,test}/**/*.{ex,exs}" + "{lib,test,bench}/**/*.{ex,exs}" ], line_length: 88 ] diff --git a/bench/scripts/macro/all_bench.exs b/bench/scripts/macro/all_bench.exs index cb711b1..5716381 100644 --- a/bench/scripts/macro/all_bench.exs +++ b/bench/scripts/macro/all_bench.exs @@ -43,8 +43,7 @@ Benchee.run( jobs, formatters: [ Benchee.Formatters.Console, - {Benchee.Formatters.Markdown, - file: Path.join(path, "all.md")} + {Benchee.Formatters.Markdown, file: Path.join(path, "all.md")} ], time: 10, after_each: fn results -> diff --git a/bench/scripts/macro/insert_bench.exs b/bench/scripts/macro/insert_bench.exs index 976cd76..3c642ed 100644 --- a/bench/scripts/macro/insert_bench.exs +++ b/bench/scripts/macro/insert_bench.exs @@ -37,8 +37,7 @@ Benchee.run( inputs: inputs, formatters: [ Benchee.Formatters.Console, - {Benchee.Formatters.Markdown, - file: Path.join(path, "insert.md")} + {Benchee.Formatters.Markdown, file: Path.join(path, "insert.md")} ] ) diff --git a/bench/scripts/micro/load_bench.exs b/bench/scripts/micro/load_bench.exs index aad4b57..3e70ec1 100644 --- a/bench/scripts/micro/load_bench.exs +++ b/bench/scripts/micro/load_bench.exs @@ -30,7 +30,8 @@ inputs = %{ 1..1_000_000 |> Enum.map(fn _ -> %{name: "Alice", email: "email@email.com"} end), "Time attr" => 1..100_000 |> Enum.map(fn _ -> %{name: "Alice", time_attr: ~T[21:25:04.361140]} end), - "Date attr" => 1..100_000 |> Enum.map(fn _ -> %{name: "Alice", date_attr: ~D[2018-06-20]} end), + "Date attr" => + 1..100_000 |> Enum.map(fn _ -> %{name: "Alice", date_attr: ~D[2018-06-20]} end), # "NaiveDateTime attr" => # 1..100_000 # |> Enum.map(fn _ -> %{name: "Alice", naive_datetime_attr: ~N[2019-06-20 21:32:07.424178]} end), @@ -40,7 +41,9 @@ inputs = %{ } jobs = %{ - "SQLite3 Loader" => fn data -> Enum.map(data, &Ecto.Bench.SQLite3Repo.load(User, &1)) end, + "SQLite3 Loader" => fn data -> + Enum.map(data, &Ecto.Bench.SQLite3Repo.load(User, &1)) + end, "Pg Loader" => fn data -> Enum.map(data, &Ecto.Bench.PgRepo.load(User, &1)) end, "MyXQL Loader" => fn data -> Enum.map(data, &Ecto.Bench.MyXQLRepo.load(User, &1)) end } @@ -52,7 +55,6 @@ Benchee.run( inputs: inputs, formatters: [ Benchee.Formatters.Console, - {Benchee.Formatters.Markdown, - file: Path.join(path, "load.md")} + {Benchee.Formatters.Markdown, file: Path.join(path, "load.md")} ] ) diff --git a/bench/scripts/micro/to_sql_bench.exs b/bench/scripts/micro/to_sql_bench.exs index 5a16a18..19abead 100644 --- a/bench/scripts/micro/to_sql_bench.exs +++ b/bench/scripts/micro/to_sql_bench.exs @@ -49,9 +49,13 @@ inputs = %{ } jobs = %{ - "SQLite3 Query Builder" => fn {type, query} -> Ecto.Bench.SQLite3Repo.to_sql(type, query) end, + "SQLite3 Query Builder" => fn {type, query} -> + Ecto.Bench.SQLite3Repo.to_sql(type, query) + end, "Pg Query Builder" => fn {type, query} -> Ecto.Bench.PgRepo.to_sql(type, query) end, - "MyXQL Query Builder" => fn {type, query} -> Ecto.Bench.MyXQLRepo.to_sql(type, query) end + "MyXQL Query Builder" => fn {type, query} -> + Ecto.Bench.MyXQLRepo.to_sql(type, query) + end } path = System.get_env("BENCHMARKS_OUTPUT_PATH") || "bench/results" @@ -61,7 +65,6 @@ Benchee.run( inputs: inputs, formatters: [ Benchee.Formatters.Console, - {Benchee.Formatters.Markdown, - file: Path.join(path, "to_sql.md")} + {Benchee.Formatters.Markdown, file: Path.join(path, "to_sql.md")} ] ) From 21ac763640da68138bc6456670fbacb717340d9c Mon Sep 17 00:00:00 2001 From: Kevin Lang Date: Tue, 23 Mar 2021 22:17:53 -0400 Subject: [PATCH 3/3] clean up lockfile --- mix.lock | 2 -- 1 file changed, 2 deletions(-) diff --git a/mix.lock b/mix.lock index 48c6ca4..4a97190 100644 --- a/mix.lock +++ b/mix.lock @@ -1,7 +1,5 @@ %{ "benchee": {:hex, :benchee, "1.0.1", "66b211f9bfd84bd97e6d1beaddf8fc2312aaabe192f776e8931cb0c16f53a521", [:mix], [{:deep_merge, "~> 1.0", [hex: :deep_merge, repo: "hexpm", optional: false]}], "hexpm", "3ad58ae787e9c7c94dd7ceda3b587ec2c64604563e049b2a0e8baafae832addb"}, - "benchee_html": {:hex, :benchee_html, "1.0.0", "5b4d24effebd060f466fb460ec06576e7b34a00fc26b234fe4f12c4f05c95947", [:mix], [{:benchee, ">= 0.99.0 and < 2.0.0", [hex: :benchee, repo: "hexpm", optional: false]}, {:benchee_json, "~> 1.0", [hex: :benchee_json, repo: "hexpm", optional: false]}], "hexpm", "5280af9aac432ff5ca4216d03e8a93f32209510e925b60e7f27c33796f69e699"}, - "benchee_json": {:hex, :benchee_json, "1.0.0", "cc661f4454d5995c08fe10dd1f2f72f229c8f0fb1c96f6b327a8c8fc96a91fe5", [:mix], [{:benchee, ">= 0.99.0 and < 2.0.0", [hex: :benchee, repo: "hexpm", optional: false]}, {:jason, "~> 1.0", [hex: :jason, repo: "hexpm", optional: false]}], "hexpm", "da05d813f9123505f870344d68fb7c86a4f0f9074df7d7b7e2bb011a63ec231c"}, "benchee_markdown": {:hex, :benchee_markdown, "0.2.6", "52fe95c8a4a744e5127264c3cb72db70f2adcc05113139e0a0b69b4df9e95ada", [:mix], [{:benchee, ">= 0.99.0 and < 2.0.0", [hex: :benchee, repo: "hexpm", optional: false]}], "hexpm", "0c2cb871befab33ab79ab204391400983c3a3aad55a3c0e2f0aac31a8b445ca4"}, "connection": {:hex, :connection, "1.1.0", "ff2a49c4b75b6fb3e674bfc5536451607270aac754ffd1bdfe175abe4a6d7a68", [:mix], [], "hexpm", "722c1eb0a418fbe91ba7bd59a47e28008a189d47e37e0e7bb85585a016b2869c"}, "db_connection": {:hex, :db_connection, "2.3.1", "4c9f3ed1ef37471cbdd2762d6655be11e38193904d9c5c1c9389f1b891a3088e", [:mix], [{:connection, "~> 1.0", [hex: :connection, repo: "hexpm", optional: false]}], "hexpm", "abaab61780dde30301d840417890bd9f74131041afd02174cf4e10635b3a63f5"},