DoT.js vs TrimPath

JavaScript performance comparison

Revision 21 of this test case created by meikidd

Preparation code

<script src="http://code.jquery.com/jquery-1.4.3.min.js">
</script>
<script src="https://github.com/olado/doT/raw/master/doT.js">
</script>
<script src="http://trimpath.googlecode.com/files/trimpath-template-1.0.38.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.doTtemplate = doT.template('{{ for (var i = 0, l = it.Accounts.length; i < l; i++) { }}<h2 class="title">{{=it.Accounts[i].AccountId}}<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].CashBalance}}</span></li><li class="collapsible"><div class="collapsible-header"><strong class="label">Account value</strong><span class="value">{{=it.Accounts[i].TotalValue}}</span></div><div class="collapsible-content"><ul class="value-list"><li><strong>Cash Balance</strong>{{=it.Accounts[i].CashBalance}}</li><li><strong>Non-margin positions</strong>{{=it.Accounts[i].NonMarginPositionsValue}}</li><li><strong>Unrealised margin profit/loss</strong>{{=it.Accounts[i].UnrealizedMarginProfitLoss}}</li><li><strong>Cost to close</strong>{{=it.Accounts[i].CostToClosePositions}}</li><li><strong>Transactions not booked</strong>{{=it.Accounts[i].TransactionsNotBooked}}</li></ul></div></li><li class="collapsible"><div class="collapsible-header"><strong class="label">Margin available</strong><span class="value">{{=it.Accounts[i].MarginAvailableForTrading}}</span></div><div class="collapsible-content"><ul class="value-list"><li><strong>Account value</strong>{{=it.Accounts[i].TotalValue}}</li><li><strong>Other collateral</strong>{{=it.Accounts[i].OtherCollateral}}</li><li><strong>Not available as margin collateral</strong>{{=it.Accounts[i].MarginCollateralNotAvailable}}</li><li><strong>Used for margin requirements</strong>{{=it.Accounts[i].MarginUsedByCurrentPositions}}</li><li><strong>Net exposure</strong>{{=it.Accounts[i].MarginNetExposure}}</li><li><strong>Exposure Coverage</strong>{{=it.Accounts[i].MarginExposureCoveragePct}}%</li></ul></div></li><li><strong class="label">Margin Utilisation</strong><div class="value">{{=it.Accounts[i].MarginUtilizationPct}}%<span class="progress"><span class="progress-value" style="width:{{=it.Accounts[i].MarginUtilizationPct}}%"></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>&nbsp;<button class="btn refresh"><span class="icon icon-refresh"></span></button></p>');



window.trimpath= TrimPath.parseTemplate('{for i_index in Accounts}<h2 class="title">${Accounts[i_index].AccountId}<small class="currency">${Accounts[i_index].BaseCurrency}</small></h2><ul class="list group"><li><strong class="label">Cash Balance</strong><span class="value">${Accounts[i_index].CashBalance}</span></li><li class="collapsible"><div class="collapsible-header"><strong class="label">$Account value</strong><span class="value">${Accounts[i_index].TotalValue}</span></div><div class="collapsible-content"><ul class="value-list"><li><strong>Cash Balance</strong>${Accounts[i_index].CashBalance}</li><li><strong>Non-margin positions</strong>${Accounts[i_index].NonMarginPositionsValue}</li><li><strong>Unrealised margin profit/loss</strong>${Accounts[i_index].UnrealizedMarginProfitLoss}</li><li><strong>Cost to close</strong>${Accounts[i_index].CostToClosePositions}</li><li><strong>Transactions not booked</strong>${Accounts[i_index].TransactionsNotBooked}</li></ul></div></li><li class="collapsible"><div class="collapsible-header"><strong class="label">Margin available</strong><span class="value">${Accounts[i_index].MarginAvailableForTrading}</span></div><div class="collapsible-content"><ul class="value-list"><li><strong>Account value</strong>${Accounts[i_index].TotalValue}</li><li><strong>Other collateral</strong>${Accounts[i_index].OtherCollateral}</li><li><strong>Not available as margin collateral</strong>${Accounts[i_index].MarginCollateralNotAvailable}</li><li><strong>Used for margin requirements</strong>${Accounts[i_index].MarginUsedByCurrentPositions}</li><li><strong>Net exposure</strong>${Accounts[i_index].MarginNetExposure}</li><li><strong>Exposure Coverage</strong>${Accounts[i_index].MarginExposureCoveragePct}%</li></ul></div></li><li><strong class="label">Margin Utilisation</strong><div class="value">${Accounts[i_index].MarginUtilizationPct}%<span class="progress"><span class="progress-value" style="width:${Accounts[i_index].MarginUtilizationPct}%"></span></span></div></li></ul>{/for}<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>&nbsp;<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>

Preparation code output

Test runner

Warning! For accurate results, please disable Firebug before running the tests. (Why?)

Java applet disabled.

Testing in unknown unknown
Test Ops/sec
doT
result.innerHTML = doTtemplate(sharedVariables);
pending…
TrimPath
result.innerHTML = trimpath.process(sharedVariables);
pending…

Compare results of other browsers

Revisions

You can edit these tests or add even more tests to this page by appending /edit to the URL. Here’s a list of current revisions for this page:

0 comments

Add a comment