csstext vs styles single (v4)

Revision 4 of this benchmark created on


Preparation HTML

<div id="myid" style="position: absolute; background-color: #333333; width: 100px; height: 100px;">
</div>
<script>
  var test = document.getElementById('myid');
</script>

Setup

var count=0;

Test runner

Ready to run.

Testing in
TestOps/sec
cssText
count++;
var size = count / 10;

if (count % 2 == 0) {
    test.style.cssText = "position: absolute; background-color: #333333; width: " + size + "px; height: " + size + "px; top: " + size + "px;";
}
else {
    test.style.cssText = "position: absolute; background-color: #333333; width: " + size + "px; left: " + size + "px; bottom: " + size + "px;";
}
ready
Individual style
count++;
var size = count / 10;

if (count % 2 == 0) {
    test.style.width = size + "px";
    test.style.height = size + "px";
    test.style.top = size + "px";
    test.style.left = "";
    test.style.bottom = "";
}
else {
    test.style.width = size + "px";
    test.style.height = "";
    test.style.top = "";
    test.style.left = size + "px";
    test.style.bottom = size + "px";
}
ready

Revisions

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