translate3d vs translate XY vs css left/top vs transition Version2 (v41)

Revision 41 of this benchmark created on


Preparation HTML

<div id="elem" style="position: absolute; background:#ccc; width:10px; height:10px;">
</div>
<script>
  var elem = document.getElementById("elem");
  var len=700;
</script>

Setup

elem.style.MozTransition = '';
    elem.style.webkitTransition = '';
    elem.style.OTransition = '';
    elem.style.transition = '';
    elem.style.msTransition = '';
    elem.style.MozTransform = '';
    elem.style.webkitTransform = '';
    elem.style.OTransform = '';
    elem.style.msTransform = '';

Teardown


    elem.style.MozTransition = '';
    elem.style.webkitTransition = '';
    elem.style.OTransition = '';
    elem.style.transition = '';
    elem.style.msTransition = '';
    elem.style.MozTransform = '';
    elem.style.webkitTransform = '';
    elem.style.OTransform = '';
    elem.style.msTransform = '';
  

Test runner

Ready to run.

Testing in
TestOps/sec
translate3d
var x = y = 0;
for (var i = 0; i<len; i++) {
  x = i;
  //y = i * 5;
  var transform = 'translate3d(' + x + 'px, ' + y + 'px, 0)';
  elem.style.MozTransform = transform;
  elem.style.webkitTransform = transform;
  elem.style.OTransform = transform;
}
ready
translateX/Y
var x = y = 0;
for (var i = 0; i<len; i++) {
  x = i;
  //y = i * 5;
  var transform = 'translateX(' + x + 'px) translateY(' + y + 'px)';
  elem.style.MozTransform = transform;
  elem.style.webkitTransform = transform;
  elem.style.OTransform = transform
}
ready
css left/top
var x = y = 0;
for (var i = 0; i<len; i++) {
  x = i;
  //y = i * 5;
  elem.style.left = x + 'px';
  elem.style.top = y + 'px';
}
ready
transition
var transition = 'all 0.1s linear';
elem.style.MozTransition = transition;
elem.style.webkitTransition = transition;
elem.style.OTransition = transition;
elem.style.transition = transition;

var x = y = 0;
for (var i = 0; i<len; i++) {
  x = i;
  //y = i * 5;
  elem.style.left = x + 'px';
  elem.style.top = y + 'px';
}
ready

Revisions

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