styleSheet API

JavaScript performance comparison

Test case created by Ickata

Preparation code

<style id="style"></style>

<script src="https://rawgit.com/ickata/utilities/master/JavaScript/Source/stylesheet-api.js"></script>

<script>
var div = document.body.appendChild( document.createElement('div') );
var html = ['<table id="table">'];
for ( var i=0; i<2000; i += 1 ) {
   html.push('<tr>');
   for ( var j=0; j<10; j += 1 ) {
      html.push('<td>test</td>');
   }
   html.push('</tr>');
}
div.innerHTML = html.join('') + '</table>';
</script>
    

Preparation code output

<style id="style"></style>

Test runner

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

Java applet disabled.

Testing in CCBot 2.0.0 / Other 0.0.0
Test Ops/sec
td.style.backgroundColor
var cells = document.getElementById('table').getElementsByTagName('td');
for ( var i=0, l=cells.length; i<l; i += 1 ) {
   cells[i].style.backgroundColor = 'red';
}
pending…
style.innerHTML
document.getElementById('style').innerHTML = '#table td { background: red }';
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.

0 Comments