ten.js performance test (v2)

Revision 2 of this benchmark created by Kevin on


Description

Possibly broken at the moment.

  • test
  • fjlksk

Some redundant code.

In simpler tests, ten wasn't dominating everything quite as much. Not sure what's slowing the other libraries down, but here you go.

There is just one minor differences in the ten test code compared to the others. Within the each function, the returned element does not to be wrapped with $(element), it is already returned as a ten object.

Preparation HTML

<script src="https://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js">
</script>
<script src="http://cdn.jqmobi.com/1.11/jq.mobi.min.js">
</script>
<script src="http://zeptojs.com/zepto.min.js">
</script>
<script src="http://lordsnow.net/kvf/ten/ten.min.js">
</script>
<div id="jswrapper">
</div>

Setup

var i = 0,
        passes = 1,
        ul, li;

Teardown


    document.getElementById("jswrapper").innerHTML = "";
  

Test runner

Ready to run.

Testing in
TestOps/sec
ten.js
(function($) {
  ul = $("<ul/>").addClass("ten-test");
  for (var ind = 0; ind < 5; ind++) {
    li = $("<li>hello world</li>");
    ul.append(li);
  }
  $("#jswrapper").append(ul);
  $("#jswrapper>ul.ten-test").each(function(index, element) {
    element.find("li").each(function(innerIndex, innerElement) {
      var elem = innerElement.html(innerIndex + ": ten item");
      !elem.hasClass("added-class") && elem.addClass("added-class");
    });
  });
})(ten);
ready
jQuery
(function($) {
  ul = $("<ul/>").addClass("jquery-test");
  for (var ind = 0; ind < 5; ind++) {
    li = $("<li>hello world</li>");
    ul.append(li);
  }
  $("#jswrapper").append(ul);
  $("#jswrapper>ul.jquery-test").each(function(index, element) {
    $(element).find("li").each(function(innerIndex, innerElement) {
      var elem = $(innerElement).html(innerIndex + ": jquery item");
      !elem.hasClass("added-class") && elem.addClass("added-class");
    });
  });
})(jQuery);
ready
jqMobi
(function($) {
  ul = $("<ul/>").addClass("jqmobi-test");
  for (var ind = 0; ind < 5; ind++) {
    li = $("<li>hello world</li>");
    ul.append(li);
  }
  $("#jswrapper").append(ul);
  $("#jswrapper>ul.jqmobi-test").each(function(index, element) {
    $(element).find("li").each(function(innerIndex, innerElement) {
      var elem = $(innerElement).html(innerIndex + ": jqmobi item");
      !elem.hasClass("added-class") && elem.addClass("added-class");
    });
  });
})(jq);
ready
Zepto
(function($) {
  ul = $("<ul/>").addClass("zepto-test");
  for (var ind = 0; ind < 5; ind++) {
    li = $("<li>hello world</li>");
    ul.append(li);
  }
  $("#jswrapper").append(ul);
  $("#jswrapper>ul.zepto-test").each(function(index, element) {
    $(element).find("li").each(function(innerIndex, innerElement) {
      var elem = $(innerElement).html(innerIndex + ": zepto item");
      !elem.hasClass("added-class") && elem.addClass("added-class");
    });
  });
})(Zepto);
ready

Revisions

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

  • Revision 1: published by Kevin on
  • Revision 2: published by Kevin on
  • Revision 7: published by Kevin on
  • Revision 9: published by Kevin on