hogan vs dot

JavaScript performance comparison

Revision 2 of this test case created

Preparation code

<script src="http://twitter.github.com/hogan.js/builds/2.0.0/hogan-2.0.0.js">
</script>
<script src="http://olado.github.com/doT/doT.min.js">
</script>
<script>
  var ht = '{{#rooms}}\
<div class="room _r{{_id}}" data-room="{{_id}}">\
   {{#dates}}\
  <div class="timebox _d{{days}}" data-days="{{days}}">\
    <div class="hours">\
      <div data-start="9"></div>\
      <div data-start="10"></div>\
      <div data-start="11"></div>\
      <div data-start="12"></div>\
      <div data-start="13"></div>\
      <div data-start="14"></div>\
      <div data-start="15"></div>\
      <div data-start="16"></div>\
      <div data-start="17"></div>\
    </div>\
    <div class="bookings"></div>\
  </div>\
  {{/dates}}\
 </div>\
 {{/rooms}}'
;
  var dt = '{{~it.rooms :room:index}}\
<div class="room _r{{=room._id}}" data-room="{{=room._id}}">\
  {{~it.dates :date:index2}}\
  <div class="timebox _d{{=date.days}}" data-days="{{=date.days}}">\
    <div class="hours">\
      <div data-start="9"></div>\
      <div data-start="10"></div>\
      <div data-start="11"></div>\
      <div data-start="12"></div>\
      <div data-start="13"></div>\
      <div data-start="14"></div>\
      <div data-start="15"></div>\
      <div data-start="16"></div>\
      <div data-start="17"></div>\
    </div>\
    <div class="bookings"></div>\
  </div>\
  {{~}}\
</div>\
{{~}}'
;
  var h = Hogan.compile(ht);
  var dot = doT.template(dt);

  var rooms = [],
      dates = [];
  for (var r = 0; r < 10; r++) {
    rooms.push({
      _id: r,
      title: 'room' + r
    });
  }
  for (var d = 0; d < 60; d++) {
    dates.push({
      days: d,
      others: 'test' + d
    });
  }
</script>

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
Hogan
h.render({
  rooms: rooms,
  dates: dates
})
pending…
doT
dot({
  rooms: rooms,
  dates: dates
})
pending…
doT eith compile
dot = doT.template(dt);dot({
  rooms: rooms,
  dates: dates
})
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