[erlang-questions] Proper replacement for io_lib:format due to low speed

Pierre Fenoll pierrefenoll@REDACTED
Sun Mar 22 10:22:42 CET 2015

Hi Max,

How about just generating an iolist?
You could write a simple function for this FmtStr case that outputs an
iolist and thus does not do too much copying and allocation.
Also how much faster is io_libc/format/2 compared to io_libc?
Just curious.

Pierre Fenoll

On 22 March 2015 at 02:01, Max Lapshin <max.lapshin@REDACTED> wrote:

> Hi.
> I've met again performance problem with io_lib:format.
> iso8601({{Y,Mo,D}, {H,Mn,S}}) ->
>   FmtStr = "~4.10.0B-~2.10.0B-~2.10.0BT~2.10.0B:~2.10.0B:~2.10.0BZ",
>   IsoStr = io_lib:format(FmtStr, [Y, Mo, D, H, Mn, S]),
>   list_to_binary(IsoStr).
> Such code is a 0,01% of business logic of one small part of flussonic, but
> it takes about 95% of time to make 10% of text output.
> I've solved this problem via https://github.com/maxlapshin/io_libc  but
> I'm not sure that it is
> a best way to do.  Maybe this is better solved in pure erlang?
> Perhaps I'm not alone with this problem and somebody has some better idea
> than just exposing fprinf via nif?
> _______________________________________________
> erlang-questions mailing list
> erlang-questions@REDACTED
> http://erlang.org/mailman/listinfo/erlang-questions
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20150322/57a0cebb/attachment.htm>

More information about the erlang-questions mailing list