<div dir="ltr"><div><div><div>Hi Max,<br><br></div>Is something like this not good enough in terms of speed?<br><br>iso8601({{Y,Mo,D}, {H,Mn,S}}) -><br> list_to_binary([integer_to_list(Y), $-,<br> two_digit_str(Mo), $-,<br> two_digit_str(D), $T,<br> two_digit_str(H), $:,<br> two_digit_str(Mn), $:,<br> two_digit_str(S), $Z]).<br><br>two_digit_str(X) when X < 10 -><br> [$0 | integer_to_list(X)];<br>two_digit_str(X) -><br> integer_to_list(X).<br><br><br></div>cheers,<br></div>Chandru<br><br></div><div class="gmail_extra"><br><div class="gmail_quote">On 22 March 2015 at 09:01, Max Lapshin <span dir="ltr"><<a href="mailto:max.lapshin@gmail.com" target="_blank">max.lapshin@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">Hi.<div><br></div><div>I've met again performance problem with io_lib:format.</div><div><br></div><div><div>iso8601({{Y,Mo,D}, {H,Mn,S}}) -></div><div> FmtStr = "~4.10.0B-~2.10.0B-~2.10.0BT~2.10.0B:~2.10.0B:~2.10.0BZ",</div><div> IsoStr = io_lib:format(FmtStr, [Y, Mo, D, H, Mn, S]),</div><div> list_to_binary(IsoStr). </div></div><div><br></div><div><br></div><div>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.</div><div><br></div><div><br></div><div>I've solved this problem via <a href="https://github.com/maxlapshin/io_libc" target="_blank">https://github.com/maxlapshin/io_libc</a> but I'm not sure that it is</div><div>a best way to do. Maybe this is better solved in pure erlang?</div><div><br></div><div><br></div><div>Perhaps I'm not alone with this problem and somebody has some better idea than just exposing fprinf via nif?</div></div>
<br>_______________________________________________<br>
erlang-questions mailing list<br>
<a href="mailto:erlang-questions@erlang.org">erlang-questions@erlang.org</a><br>
<a href="http://erlang.org/mailman/listinfo/erlang-questions" target="_blank">http://erlang.org/mailman/listinfo/erlang-questions</a><br>
<br></blockquote></div><br></div>