jsPerf.app is an online JavaScript performance benchmark test runner & jsperf.com mirror. It is a complete rewrite in homage to the once excellent jsperf.com now with hopefully a more modern & maintainable codebase.
jsperf.com URLs are mirrored at the same path, e.g:
https://jsperf.com/negative-modulo/2
Can be accessed at:
https://jsperf.app/negative-modulo/2
Appending HTML to the page with doT, Mustache and native Javascript
<script src="http://github.com/janl/mustache.js/raw/master/mustache.js"></script>
<script src="https://github.com/olado/doT/raw/master/doT.js"></script>
<script>
window.sharedVariables = {"Accounts":[{"id":"XNKN_2147042265","AccountId":"XNKN_2147042265","BaseCurrency":"USD","BaseCurrencyDecimals":2,"LegalInstruments":460031,"CashBalance":10054873.73,"NonMarginPositionsValue":0,"UnrealizedMarginProfitLoss":139392.38,"CostToClosePositions":0,"MarginAvailableForTrading":10115221.041784238,"TransactionsNotBooked":0,"TotalValue":10194266.110000001,"OtherCollateral":100000,"MarginCollateralNotAvailable":0,"MarginUsedByCurrentPositions":-179045.06821576256,"MarginNetExposure":4476126.705390137,"MarginExposureCoveragePct":229.98156190716585,"MarginUtilizationPct":1.7392698644329347}]};
window.mustacheTemplate = '{{#Accounts}}<h2 class="title {{AccountTitleClass}}">{{FormattedAccountName}}<small class="currency">{{BaseCurrency}}</small></h2><ul class="list group"><li><strong class="label">Cash Balance</strong><span class="value">{{{CashBalanceFormatted}}}</span></li><li class="collapsible"><div class="collapsible-header"><strong class="label">Account value</strong><span class="value">{{{TotalValueFormatted}}}</span></div><div class="collapsible-content"><ul class="value-list"><li><strong>Cash Balance</strong>{{{CashBalanceFormatted}}}</li><li><strong>Non-margin positions</strong>{{{NonMarginPositionsValueFormatted}}}</li><li><strong>Unrealised margin profit/loss</strong>{{{UnrealizedMarginProfitLossFormatted}}}</li><li><strong>Cost to close</strong>{{{CostToClosePositionsFormatted}}}</li><li><strong>Transactions not booked</strong>{{{TransactionsNotBookedFormatted}}}</li></ul></div></li><li class="collapsible"><div class="collapsible-header"><strong class="label">Margin available</strong><span class="value">{{{MarginAvailableForTradingFormatted}}}</span></div><div class="collapsible-content"><ul class="value-list"><li><strong>Account value</strong>{{{TotalValueFormatted}}}</li><li><strong>Other collateral</strong>{{{OtherCollateralFormatted}}}</li><li><strong>Not available as margin collateral</strong>{{{MarginCollateralNotAvailableFormatted}}}</li><li><strong>Used for margin requirements</strong>{{{MarginUsedByCurrentPositionsFormatted}}}</li><li><strong>Net exposure</strong>{{{MarginNetExposureFormatted}}}</li><li><strong>Exposure Coverage</strong>{{{MarginExposureCoveragePctFormatted}}}%</li></ul></div></li><li><strong class="label">Margin Utilisation</strong><div class="value">{{{MarginUtilizationPctWithMaxFormatted}}}%<span class="progress"><span class="progress-value" style="width:{{{MarginUtilizationPctWithMax}}}%"></span></span></div></li></ul>{{/Accounts}} <ul class="list link-list group"><li><a href="#/orders/">Open Orders</a></li><li><a href="#/positions/">Open Positions</a></li></ul> <p class="timestamp">Last updated: <span id="AccUpd">-</span> <button class="btn refresh"><span class="icon icon-refresh"></span></button></p>';
window.doTtemplate = doT.template('{{ for (var i = 0, l = it.Accounts.length; i < l; i++) { }}<h2 class="title {{=it.Accounts[i].AccountTitleClass()}}">{{=it.Accounts[i].FormattedAccountName()}}<small class="currency">{{=it.Accounts[i].BaseCurrency}}</small></h2><ul class="list group"><li><strong class="label">Cash Balance</strong><span class="value">{{=it.Accounts[i].CashBalanceFormatted()}}</span></li><li class="collapsible"><div class="collapsible-header"><strong class="label">Account value</strong><span class="value">{{=it.Accounts[i].TotalValueFormatted()}}</span></div><div class="collapsible-content"><ul class="value-list"><li><strong>Cash Balance</strong>{{=it.Accounts[i].CashBalanceFormatted()}}</li><li><strong>Non-margin positions</strong>{{=it.Accounts[i].NonMarginPositionsValueFormatted()}}</li><li><strong>Unrealised margin profit/loss</strong>{{=it.Accounts[i].UnrealizedMarginProfitLossFormatted()}}</li><li><strong>Cost to close</strong>{{=it.Accounts[i].CostToClosePositionsFormatted()}}</li><li><strong>Transactions not booked</strong>{{=it.Accounts[i].TransactionsNotBookedFormatted()}}</li></ul></div></li><li class="collapsible"><div class="collapsible-header"><strong class="label">Margin available</strong><span class="value">{{=it.Accounts[i].MarginAvailableForTradingFormatted()}}</span></div><div class="collapsible-content"><ul class="value-list"><li><strong>Account value</strong>{{=it.Accounts[i].TotalValueFormatted()}}</li><li><strong>Other collateral</strong>{{=it.Accounts[i].OtherCollateralFormatted()}}</li><li><strong>Not available as margin collateral</strong>{{=it.Accounts[i].MarginCollateralNotAvailableFormatted()}}</li><li><strong>Used for margin requirements</strong>{{=it.Accounts[i].MarginUsedByCurrentPositionsFormatted()}}</li><li><strong>Net exposure</strong>{{=it.Accounts[i].MarginNetExposureFormatted()}}</li><li><strong>Exposure Coverage</strong>{{=it.Accounts[i].MarginExposureCoveragePctFormatted()}}%</li></ul></div></li><li><strong class="label">Margin Utilisation</strong><div class="value">{{=it.Accounts[i].MarginUtilizationPctWithMaxFormatted()}}%<span class="progress"><span class="progress-value" style="width:{{=it.Accounts[i].MarginUtilizationPctWithMax()}}%"></span></span></div></li></ul>{{ } }} <ul class="list link-list group"><li><a href="#/orders/">Open Orders</a></li><li><a href="#/positions/">Open Positions</a></li></ul> <p class="timestamp">Last updated: <span id="AccUpd">-</span> <button class="btn refresh"><span class="icon icon-refresh"></span></button></p>"');
var result = document.getElementById('result');
</script>
<style>#result {display:none;}</style>
<div id="result"></div>
Ready to run.
Test | Ops/sec | |
---|---|---|
doT |
| ready |
mustache |
| ready |
plain html |
| ready |
You can edit these tests or add more tests to this page by appending /edit to the URL.