Efficient binary creation
Nicholas Frechette
zeno490@REDACTED
Mon Mar 7 03:31:38 CET 2011
Hi,
I was profiling my erlang application and found out that I am spending quite
a bit of time building binaries.
I was wondering what is the most efficient way to create a large binary?
>From an IO list?
Bin = iolist_to_binary(List).
>From the front?
Bin = <<NewData/binary, ExistingData/binary>>.
>From the back?
Bin = <<ExistingData/binary, NewData/binary>>.
I'm currently building a list of binaries (each a couple bytes long, 17-44).
Since I'm moving that data from process to process and sending it over a
socket, I presume it would be best to either create an IO list of larger
binaries (fewer items to copy) or a single binary and then iterate over it
to send it over a socket in chuncks.
Tips?
Thanks!
Nicholas
More information about the erlang-questions
mailing list