Skip to content

Commit d00dae1

Browse files
committed
number the inputs to keep order, use Stream, add a control test
Stream removes some of the overhead jitter of Enum, and having a control test helps one understand what the overhead of the test itself is versus what sort of time is being spent in EctoSQL modules
1 parent 8f1996c commit d00dae1

1 file changed

Lines changed: 15 additions & 14 deletions

File tree

bench/scripts/micro/load_bench.exs

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -22,25 +22,26 @@ Code.require_file("../../support/setup.exs", __DIR__)
2222
alias Ecto.Bench.User
2323

2424
inputs = %{
25-
"Small 1 Thousand" =>
26-
1..1_000 |> Enum.map(fn _ -> %{name: "Alice", email: "email@email.com"} end),
27-
"Medium 100 Thousand" =>
28-
1..100_000 |> Enum.map(fn _ -> %{name: "Alice", email: "email@email.com"} end),
29-
"Big 1 Million" =>
30-
1..1_000_000 |> Enum.map(fn _ -> %{name: "Alice", email: "email@email.com"} end),
31-
"Time attr" =>
32-
1..100_000 |> Enum.map(fn _ -> %{name: "Alice", time_attr: ~T[21:25:04.361140]} end),
33-
"Date attr" => 1..100_000 |> Enum.map(fn _ -> %{name: "Alice", date_attr: ~D[2018-06-20]} end),
34-
"NaiveDateTime attr" =>
25+
"1. Small 1 Thousand" =>
26+
1..1_000 |> Stream.map(fn _ -> %{name: "Alice", email: "email@email.com"} end),
27+
"2. Medium 100 Thousand" =>
28+
1..100_000 |> Stream.map(fn _ -> %{name: "Alice", email: "email@email.com"} end),
29+
"3. Big 1 Million" =>
30+
1..1_000_000 |> Stream.map(fn _ -> %{name: "Alice", email: "email@email.com"} end),
31+
"4. Time attr" =>
32+
1..100_000 |> Stream.map(fn _ -> %{name: "Alice", time_attr: ~T[21:25:04.361140]} end),
33+
"5. Date attr" => 1..100_000 |> Stream.map(fn _ -> %{name: "Alice", date_attr: ~D[2018-06-20]} end),
34+
"6. NaiveDateTime attr" =>
3535
1..100_000
36-
|> Enum.map(fn _ -> %{name: "Alice", naive_datetime_attr: ~N[2019-06-20 21:32:07.424178]} end),
37-
"UUID attr" =>
36+
|> Stream.map(fn _ -> %{name: "Alice", naive_datetime_attr: ~N[2019-06-20 21:32:07.424178]} end),
37+
"7. UUID attr" =>
3838
1..100_000
39-
|> Enum.map(fn _ -> %{name: "Alice", uuid: Ecto.UUID.bingenerate()} end)
39+
|> Stream.map(fn _ -> %{name: "Alice", uuid: Ecto.UUID.bingenerate()} end)
4040
}
4141

4242
jobs = %{
43-
"Pg Loader" => fn data -> Enum.map(data, &Ecto.Bench.PgRepo.load(User, &1)) end,
43+
"Control" => fn stream -> stream |> Stream.map(fn _data -> true end) |> Stream.run() end,
44+
"Pg Loader" => fn stream -> stream |> Stream.map(&Ecto.Bench.PgRepo.load(User, &1)) |> Stream.run() end,
4445
"MyXQL Loader" => fn data -> Enum.map(data, &Ecto.Bench.MyXQLRepo.load(User, &1)) end
4546
}
4647

0 commit comments

Comments
 (0)