Table Creation

JavaScript performance comparison

Revision 2 of this test case created

Preparation code

<script src="//ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js">
</script>
<table id="table">
  <tbody id="mybody">
  </tbody>
</table>
<script>
Benchmark.prototype.teardown = function() {
    $('#table').empty();
};
</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
Inner HTML * 1000
var t = document.getElementById('table');
var s = ''
for (var i = 0; i < 1000; ++i) {
  s += "<tr><td>" + i + "</td></tr>";
}
t.innerHTML = s;
pending…
DOM
var tbody = document.createElement('tbody');
for (var i = 0; i < 1000; ++i) {
  var td = document.createElement('td');
  td.textContent = i;
  var tr = document.createElement('tr');
  tr.appendChild(td);
  tbody.appendChild(tr);
}
var table = document.getElementById('table');
table.textContent = null;
table.appendChild(tbody);
pending…
tables
var tbody = document.createElement('tbody');
for (var i = 0; i < 1000; ++i) {
  var tr = tbody.insertRow();
  var td = tr.insertCell();
  td.textContent = i;
}
var table = document.getElementById('table');
table.textContent = null;
table.appendChild(tbody);
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