forked from plausible/ch
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathencode.exs
More file actions
27 lines (23 loc) · 695 Bytes
/
encode.exs
File metadata and controls
27 lines (23 loc) · 695 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
IO.puts("""
This benchmark measures the performance of encoding rows in RowBinary format.
""")
alias Ch.RowBinary
types = ["UInt64", "String", "Array(UInt8)", "DateTime"]
rows = fn count ->
Enum.map(1..count, fn i ->
[i, "Golang SQL database driver", [1, 2, 3, 4, 5, 6, 7, 8, 9], DateTime.utc_now()]
end)
end
Benchee.run(
%{
"RowBinary" => fn rows -> RowBinary.encode_rows(rows, types) end,
"RowBinary stream" => fn rows ->
Stream.chunk_every(rows, 60_000)
|> Stream.each(fn chunk -> RowBinary.encode_rows(chunk, types) end)
|> Stream.run()
end
},
inputs: %{
"1_000_000 (UInt64, String, Array(UInt8), DateTime) rows" => rows.(1_000_000)
}
)