var-loop

JavaScript performance comparison

Revision 4 of this test case created

Preparation code

<html>
 
  <head>
    <script src="//ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js">
    </script>
  </head>
 
  <body>
    <div id="dom">
    </div>
  </body>

</html>
<script>
Benchmark.prototype.setup = function() {
    var $dom = $("#dom");
    var dom = document.getElementById("dom");
    var testCount = 10000;
};

Benchmark.prototype.teardown = function() {
    $dom.children().remove();
};
</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
innerHTML
var htm = "<table>";
for (var i = 0; i < testCount; i++) {
  var tr = '<tr>';
  tr += '<th>' + i + '</th>';
  tr += '<td>コンテンツ-' + i + '</td>';
  tr += '<td>これはダミーです</td>';
  tr += '</tr>';
  htm += tr;
}
htm += "</table>";
dom.innerHTML = htm;
pending…
innerHTML 2
var htm = "<table>";
var tr = '';
for (var i = 0; i < testCount; i++) {
  tr = '<tr>';
  tr += '<th>' + i + '</th>';
  tr += '<td>コンテンツ-' + i + '</td>';
  tr += '<td>これはダミーです</td>';
  tr += '</tr>';
  htm += tr;
}
htm += "</table>";
dom.innerHTML = htm;
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