<html><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;" class=""><div class="">As I was surprised with the measurement myself, I am sure that compiler did some significant optimisation  — I am attaching the file with the source code, so you could review it yourself.</div><div class="">Also, it would be interesting to see how this performs on R22 (I haven’t installed it yet).</div><div class=""><br class=""></div><div class="">In my view, it doesn’t really mattar how fast the testing code is. What matter here is that there’s an order of magnitude difference in performance between the two BIFs. </div><div class=""><br class=""></div><div class="">The calling syntax for the tconvert:run/2 is: tconvert:run( a, 10000000 ).</div><div class=""><br class=""></div><div class="">The first argument is a term to be converted, and the second represents a number of iterations — higher this number, more accurate the measurement will be (at least in my opinion).</div><div class=""><br class=""></div><div class="">After reading your email I’ve looked at my code again, and noticed a potential slow-down for binary_to_term/1 portion of the test. </div><div class=""><br class=""></div><div class=""><div style="margin: 0px; font-stretch: normal; line-height: normal;" class=""><font face="Courier New" class="">do_bin_to_term( <<Bin/binary>> , 0 ) -> binary_to_term( Bin );</font></div><div style="margin: 0px; font-stretch: normal; line-height: normal;" class=""><font face="Courier New" class="">do_bin_to_term( <<Bin/binary>> , N )</font></div><div style="margin: 0px; font-stretch: normal; line-height: normal;" class=""><font face="Courier New" class="">-></font></div><div style="margin: 0px; font-stretch: normal; line-height: normal;" class=""><font face="Courier New" class="">    <b class=""><font color="#e32400" class="">binary_to_term( <<Bin/binary>> ),</font></b></font></div><div style="margin: 0px; font-stretch: normal; line-height: normal;" class=""><font face="Courier New" class="">    do_bin_to_term( Bin , N-1 )</font></div><div style="margin: 0px; font-stretch: normal; line-height: normal;" class=""><font face="Courier New" class="">.</font></div></div><div class=""><br class=""></div><div class=""><br class=""></div><div class="">When written as </div><div class=""><br class=""></div><div class=""><div class=""><div style="margin: 0px; font-stretch: normal; line-height: normal;" class=""><font face="Courier New" class="">do_bin_to_term( <<Bin/binary>> , 0 ) -> binary_to_term( Bin );</font></div><div style="margin: 0px; font-stretch: normal; line-height: normal;" class=""><font face="Courier New" class="">do_bin_to_term( <<Bin/binary>> , N )</font></div><div style="margin: 0px; font-stretch: normal; line-height: normal;" class=""><font face="Courier New" class="">-></font></div><div style="margin: 0px; font-stretch: normal; line-height: normal;" class=""><font face="Courier New" class="">    <b class=""><font color="#4e7a27" class="">binary_to_term( Bin ),</font></b></font></div><div style="margin: 0px; font-stretch: normal; line-height: normal;" class=""><font face="Courier New" class="">    do_bin_to_term( Bin , N-1 )</font></div><div style="margin: 0px; font-stretch: normal; line-height: normal;" class=""><font face="Courier New" class="">.</font></div></div></div><div class=""><font face="Courier New" class=""><br class=""></font></div><div class="">It speeds up the code by factor 2 (<b class="">well,</b> <b class="">duh! </b>Cynic would say — so much for compiler optimisation ;-))</div><div class=""><br class=""></div><div class="">After this “fix”, binary_to_term/1 portion of the test runs “only” 14 times slower.</div><div class=""><br class=""></div><div style="margin: 0px; font-stretch: normal; font-size: 11px; line-height: normal; font-family: Menlo; background-color: rgba(227, 227, 227, 0.89);" class=""><span style="font-variant-ligatures: no-common-ligatures" class="">(cig@MacBook-Pro)322> tconvert:run( a, 10000000 ).        </span></div><div style="margin: 0px; font-stretch: normal; font-size: 11px; line-height: normal; font-family: Menlo; background-color: rgba(227, 227, 227, 0.89); min-height: 13px;" class=""><span style="font-variant-ligatures: no-common-ligatures" class=""></span><br class=""></div><div style="margin: 0px; font-stretch: normal; font-size: 11px; line-height: normal; font-family: Menlo; background-color: rgba(227, 227, 227, 0.89);" class=""><span style="font-variant-ligatures: no-common-ligatures" class="">term_to_binary/1 RETURN VALUE:<<131,100,0,1,97>></span></div><div style="margin: 0px; font-stretch: normal; font-size: 11px; line-height: normal; font-family: Menlo; background-color: rgba(227, 227, 227, 0.89);" class=""><span style="font-variant-ligatures: no-common-ligatures" class="">REQUEST COUNT:10000000</span></div><div style="margin: 0px; font-stretch: normal; font-size: 11px; line-height: normal; font-family: Menlo; background-color: rgba(227, 227, 227, 0.89);" class=""><span style="font-variant-ligatures: no-common-ligatures" class="">ELAPSED TIME (usec):94664</span></div><div style="margin: 0px; font-stretch: normal; font-size: 11px; line-height: normal; font-family: Menlo; background-color: rgba(227, 227, 227, 0.89);" class=""><span style="font-variant-ligatures: no-common-ligatures" class="">TIME PER REQUEST (usec): 0.0094664</span></div><div style="margin: 0px; font-stretch: normal; font-size: 11px; line-height: normal; font-family: Menlo; background-color: rgba(227, 227, 227, 0.89);" class=""><span style="font-variant-ligatures: no-common-ligatures" class="">PROJECTED RATE (req/sec): <b class="">105636778</b>.50080284</span></div><div style="margin: 0px; font-stretch: normal; font-size: 11px; line-height: normal; font-family: Menlo; background-color: rgba(227, 227, 227, 0.89); min-height: 13px;" class=""><span style="font-variant-ligatures: no-common-ligatures" class=""></span><br class=""></div><div style="margin: 0px; font-stretch: normal; font-size: 11px; line-height: normal; font-family: Menlo; background-color: rgba(227, 227, 227, 0.89);" class=""><span style="font-variant-ligatures: no-common-ligatures" class="">binary_to_term/1 RETURN VALUE:a</span></div><div style="margin: 0px; font-stretch: normal; font-size: 11px; line-height: normal; font-family: Menlo; background-color: rgba(227, 227, 227, 0.89);" class=""><span style="font-variant-ligatures: no-common-ligatures" class="">REQUEST COUNT:10000000</span></div><div style="margin: 0px; font-stretch: normal; font-size: 11px; line-height: normal; font-family: Menlo; background-color: rgba(227, 227, 227, 0.89);" class=""><span style="font-variant-ligatures: no-common-ligatures" class="">ELAPSED TIME (usec):1385235</span></div><div style="margin: 0px; font-stretch: normal; font-size: 11px; line-height: normal; font-family: Menlo; background-color: rgba(227, 227, 227, 0.89);" class=""><span style="font-variant-ligatures: no-common-ligatures" class="">TIME PER REQUEST (usec): 0.1385235</span></div><div style="margin: 0px; font-stretch: normal; font-size: 11px; line-height: normal; font-family: Menlo; background-color: rgba(227, 227, 227, 0.89);" class=""><span style="font-variant-ligatures: no-common-ligatures" class="">PROJECTED RATE (req/sec): <b class="">7218991</b>.723425989</span></div><div style="margin: 0px; font-stretch: normal; font-size: 11px; line-height: normal; font-family: Menlo; background-color: rgba(227, 227, 227, 0.89);" class=""><span style="font-variant-ligatures: no-common-ligatures" class="">ok</span></div><div class=""> </div><div class=""><br class=""></div><div class="">Kind regards</div><div class=""><br class=""></div><div class="">V/</div><div class=""><br class=""></div><div class=""></div></body></html>