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

Max Lapshin max.lapshin@REDACTED
Sun Mar 22 10:01:32 CET 2015


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?
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20150322/defbb38a/attachment.htm>


More information about the erlang-questions mailing list