Skip to content

Commit

Permalink
Merge pull request #63 from rbino/feat/bye-bye-batches
Browse files Browse the repository at this point in the history
BREAKING: Bye bye, batches
  • Loading branch information
rbino authored Feb 27, 2025
2 parents ea33a65 + 13dbabb commit e98420e
Show file tree
Hide file tree
Showing 23 changed files with 695 additions and 2,264 deletions.
13 changes: 5 additions & 8 deletions bench/benchmark.exs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
alias TigerBeetlex.Connection
alias TigerBeetlex.Transfer
alias TigerBeetlex.TransferBatch

{:ok, _pid} =
Connection.start_link(
Expand All @@ -24,21 +23,19 @@ bench = fn ->

{total, max} =
Enum.reduce(chunks, {0, 0}, fn chunk, {time_total_us, max_batch_us} ->
batch =
Enum.reduce(chunk, TransferBatch.new!(batch_size), fn _idx, acc ->
dummy_transfer = %Transfer{
transfers =
for _idx <- chunk do
%Transfer{
id: <<0::unsigned-little-size(128)>>,
debit_account_id: <<0::unsigned-little-size(128)>>,
credit_account_id: <<0::unsigned-little-size(128)>>,
ledger: 1,
code: 1,
amount: 10
}
end

TransferBatch.append!(acc, dummy_transfer)
end)

{elapsed, response} = :timer.tc(fn -> Connection.create_transfers(:tb, batch) end)
{elapsed, response} = :timer.tc(fn -> Connection.create_transfers(:tb, transfers) end)

{:ok, results} = response

Expand Down
Loading

0 comments on commit e98420e

Please sign in to comment.