<html><head><meta http-equiv="Content-Type" content="text/html charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class="">Jose wrote:<div class=""><br class=""></div><div class="">> <span style="white-space: pre-wrap; widows: 1;" class="">I wonder how fast it would be if binary:split/3 was written as a BIF.</span></div><div class=""><br class=""></div><div class="">I wrote a BIF in 2005 for manipulating binaries. It was documented in</div><div class="">an ICFP presentation and ACM paper. You can read about it, the</div><div class="">erlang code, and more importantly the actual BIF code at my website</div><div class=""><a href="http://duomark.com/erlang/index.html" class="">http://duomark.com/erlang/index.html</a> listed under the title</div><div class="">“A Stream Library Using Erlang Binaries”. There are separate links</div><div class="">for the HTML Briefing and Code.</div><div class=""><br class=""></div><div class=""><a href="http://duomark.com/erlang/publications/acm2005.pdf" class="">http://duomark.com/erlang/publications/acm2005.pdf</a></div><div class=""><br class=""></div><div class="">From the abstract:</div><div class=""><br class=""></div><div class="">"The new BIFs are shown to improve performance as much
as 250</div><div class="">times over native erlang functions. The reduction in memory
usage</div><div class="">caused by the BIFs also allows successful processing in
situations</div><div class="">that crashed the runtime as application functions."</div><div class=""><br class=""></div><div class="">There is a gzip tar file that you used to be able to overlay on R10B(!!)</div><div class="">to build the BIFs. But it is all contained in a single stream.c file and the</div><div class="">corresponding BIF table entries are in the other parts of the erts and</div><div class="">beam directories there, so it should be easy to adapt to the current</div><div class="">release you are working with. You should be able</div><div class="">to quickly get into the source and see if it meets any of your needs.</div><div class="">It will require some modification, and there are manual loop unrolling</div><div class="">and so forth that I did for performance, but as a rough quick test of</div><div class="">whether a BIF would be helpful this might be the quickest way to get</div><div class="">started.</div><div class=""><br class=""></div><div class="">If you do achieve interesting results, be sure to add reduction count</div><div class="">bumping in the BIF. This code predates the option of doing that.</div><div class=""><br class=""></div><div class="">jay</div><div class=""><br class=""></div></body></html>