Skip to content

Commit

Permalink
refactor benchmarks a bit
Browse files Browse the repository at this point in the history
  • Loading branch information
ruslandoga committed Jan 29, 2024
1 parent 9d8e88a commit 7572662
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
8 changes: 6 additions & 2 deletions bench/insert.exs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions bench/stream.exs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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()
Expand Down

0 comments on commit 7572662

Please sign in to comment.