From 7572662505239452313b72331109b5607955678a Mon Sep 17 00:00:00 2001 From: ruslandoga <67764432+ruslandoga@users.noreply.github.com> Date: Fri, 12 Jan 2024 11:18:46 +0900 Subject: [PATCH] refactor benchmarks a bit --- bench/insert.exs | 8 ++++++-- bench/stream.exs | 4 ++-- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/bench/insert.exs b/bench/insert.exs index a8baa60..c3502a2 100644 --- a/bench/insert.exs +++ b/bench/insert.exs @@ -37,18 +37,22 @@ Benchee.run( end, # "control stream" => fn rows -> rows |> Stream.chunk_every(60_000) |> Stream.run() end, "encode stream" => fn rows -> + encoding_types = Ch.RowBinary.encoding_types(types) + rows |> Stream.chunk_every(60_000) - |> Stream.map(fn chunk -> RowBinary.encode_rows(chunk, types) end) + |> Stream.map(fn chunk -> RowBinary._encode_rows(chunk, encoding_types) end) |> Stream.run() end, "insert stream" => fn rows -> DBConnection.run( conn, fn conn -> + encoding_types = Ch.RowBinary.encoding_types(types) + rows |> Stream.chunk_every(60_000) - |> Stream.map(fn chunk -> RowBinary.encode_rows(chunk, types) end) + |> Stream.map(fn chunk -> RowBinary._encode_rows(chunk, encoding_types) end) |> Enum.into(Ch.stream(conn, statement)) end, timeout: :infinity diff --git a/bench/stream.exs b/bench/stream.exs index 5c3f140..c48196a 100644 --- a/bench/stream.exs +++ b/bench/stream.exs @@ -17,7 +17,7 @@ Benchee.run( conn, fn conn -> conn - |> Ch.stream(statement, _params = [], format: "RowBinary") + |> Ch.stream(statement, _params = [], format: "RowBinary", timeout: :infinity) |> Stream.run() end, timeout: :infinity @@ -28,7 +28,7 @@ Benchee.run( conn, fn conn -> conn - |> Ch.stream(statement, _params = [], format: "RowBinary") + |> Ch.stream(statement, _params = [], format: "RowBinary", timeout: :infinity) |> Stream.map(fn %Ch.Result{data: data} -> data |> IO.iodata_to_binary()