handob

JavaScript performance comparison

Test case created

Preparation code

<!DOCTYPE html>
<html>
<head>
<meta charset=utf-8 />
<title>HANDOB example</title>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script>
<script src="https://dl.dropboxusercontent.com/u/154493847/HANDOB.js"></script>
</head>
 
<body>
<table border="1">
  <tr>
    <td><ul data-handob-observer="the-list"></ul></td>
    <td><ul data-handob-observer="the-list"></ul></td>
  </tr>
</table>
</body>
</html>
<script>
Benchmark.prototype.setup = function() {
    var list = [];
   
    function addToList(id, text) {
      list.push({id: id, text: text});
      $(document).trigger('list-changed', [list]);
    }
   
    function addBtn(title, id) {
      $('<a data-handob-handler="add-to-list" data-item-id="'+id+'">'+title+'</a><br>').insertBefore($('body > :first-child'));
    }
};
</script>

Preparation code output

HANDOB example

      Test runner

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

      Java applet disabled.

      Testing in unknown unknown
      Test Ops/sec
      HANDOB
      HANDOB.AddHandler('add-to-list', function(event, elm) {
        addToList($(elm).data('item-id'), $(elm).text());
      })
      .AddObserver('list-changed', 'the-list', function(event, elm, list) {
        $(elm).text(JSON.stringify(list));
      });

      addBtn('Hest', 1);

      $('a').trigger('click');
      pending…
      Raw jQuery method
      $(document).on('click', '[data-handob-handler="add-to-list"]', function() {
        addToList($(this).data('item-id'), $(this).text());
      });

      $(document).on('list-changed', function(event, list) {
        $('[data-handob-observer="the-list"]').text(JSON.stringify(list));
      });

      addBtn('Hest', 1);

      $('a').trigger('click');
      pending…

      You can edit these tests or add even more tests to this page by appending /edit to the URL.

      Compare results of other browsers

      0 comments

      Add a comment