translate3d vs background-color (v122)

Revision 122 of this benchmark created on


Preparation HTML

<script src="https://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script>
<div id="elem" style="position: absolute; background-color:white; width:10px; height:10px;"></div>
<div id="elem2" style="position: absolute; background-color:black; width:10px; height:10px;"></div>
<script>
  var elem = document.getElementById("elem");
  var style = elem.style;
  var elem2 = document.getElementById("elem2");
  var style2 = elem2.style;
  var elem2j = $("#elem2");
</script>

Test runner

Ready to run.

Testing in
TestOps/sec
background-color
var high = false;

for (var i = 200; i--;) {
  if (high) {
    style2.background = 'black';
    high = false;
  } else {
    style2.background = 'white';
    high = true;
  }
}
ready
translate3d
var high = false;

for (var i = 200; i--;) {
  if (high) {
    style2.WebkitTransform = 'translate3d(0, 0, 0)';
    high = false;
  } else {
    style2.WebkitTransform = 'translate3d(1000px, 0, 0)';
    high = true;
  }
}
ready
translate
var high = false;

for (var i = 200; i--;) {
  if (high) {
    style2.WebkitTransform = 'translate(0, 0)';
    high = false;
  } else {
    style2.WebkitTransform = 'translate(1000px, 0)';
    high = true;
  }
}
ready
var high = false;

for (var i = 200; i--;) {
  if (high) {
    style2.background = '#000000';
    high = false;
  } else {
    style2.background = '#ffffff';
    high = true;
  }
}
ready

Revisions

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