<html><head></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><div>Hello,</div><div><br></div><div>Just run the test on Mac Mini: 2GHz i7, 4GB 1333 MHz (basic Min Server) with R15B</div><div><br></div><div>./configure --prefix=/usr/local/otp-R15B --enable-threads --enable-smp-support --enable-kernel-poll --enable-sctp --enable-hipe --disable-dynamic-ssl-lib --enable-darwin-64bit --enable-m64-build --without-javac</div><div><br></div><div>100 unique objects has been converted to_json and to_term about 10000 times (100 time per object) and jsx result was compared with mochijson2. Got the following results:</div><div><br></div><div>to_term</div><div> * jsx: 2231 ms, 0.223 ms per object</div><div> * mochi: 2347 ms, 0.235 ms per object</div><div><br></div><div>to_json</div><div> * jsx: 5203 ms, 0.520 ms per object</div><div> * mochi: 1511ms, 0.151 ms per object</div><div><br></div><div>The problem with jsx is inefficient json_escape algorithm that causes alot of binary string copying. </div><div>See the profile:</div><div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 12px/normal Helvetica; ">{[{{jsx_utils,json_escape,2}, 3200, 347.542, 7.202}, </div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 12px/normal Helvetica; "> {{jsx_utils,json_escape,3}, 218000, 0.000, 334.072}], </div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 12px/normal Helvetica; "> { {jsx_utils,json_escape,3}, 221200, 347.542, 341.274}, %</div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 12px/normal Helvetica; "> [{garbage_collect, 535, 5.287, 5.287}, </div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 12px/normal Helvetica; "> {suspend, 107, 0.981, 0.000}, </div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 12px/normal Helvetica; "> {{jsx_utils,json_escape,3}, 218000, 0.000, 334.072}]}.</div></div><div><br></div><div>I've made an fix to it and now</div><div><br></div><div>to_json</div><div> * jsx 2157ms, 0.217 ms per object</div><div> * mochi 1495ms, 0.150 ms per object</div><div><br></div><div>but the memory usage dynamic fir jsx if much more better (like it is reported by erlang:memory(processes)</div><div><br></div><div>* jsx from 1.921.751 to max 2.045.904</div><div>* mochi from 1.724.560 to max 4.498.640</div><div><br></div><div>As a conclusion: </div><div><br></div><div>fixed jsx ;-) is 1.45 times slower then mochijson but 2x time more memory efficient + I like jsx semantic of object encoding/decoding. BTW, I'll send you a pull request for performance fix.</div><div><br></div><div>- Dmitry</div><div><br></div><br><div><div>On Mar 21, 2012, at 4:38 PM, Tristan Sloughter wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite"><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">I'll try to run a performance comparison your code and mochiweb in my test env.<br></blockquote>
<div><br></div><div>It would be great if you included jiffy (<a href="https://github.com/davisp/jiffy">https://github.com/davisp/jiffy</a>) too and please share if you do :)</div><div><br></div><div>Tristan</div><div><br>
</div><div><br></div></div>
</blockquote></div><br></body></html>