translate3d vs translate XY vs css left/top vs scrollleft (v115)

Revision 115 of this benchmark created on


Preparation HTML

<div  id="elem2" style="width: 300px; overflow-x:scroll;white-space:nowarp; height:200px">
<div id="elem" style=" position:relative; width: 800px ; background:black;  height:100px; background-color:balck">
    
</div>
</div>
<script>
  var elem = document.getElementById("elem");
  var style= elem.style;
  var elem2 = document.getElementById("elem2");
 

</script>

Test runner

Ready to run.

Testing in
TestOps/sec
translate3d
var x = y = 0;
for (var i = 100; i--;) {
 x = i;
 y = i * 5;

 style.WebkitTransform = 'translate3d(' + x + 'px, ' + y + 'px, 0)';

}
ready
translateX/Y
var x = y = 0;
for (var i = 100; i--;) {
 x = i;
 y = i * 5;

 style.WebkitTransform = 'translateX(' + x + 'px) translateY(' + y + 'px)';

}
ready
css left/top
var x = y = 0;
for (var i = 100; i--;) {
 x = i;

 style.left = x + 'px';

}
ready
Scroll left
var x = y = 0;
for (var i = 100; i--;) {
 x = i;

 elem2.scrollLeft=i; 

}
ready
translate x/y + z
var x = y = 0;
for (var i = 100; i--;) {
 x = i;
 y = 0;

 style.WebkitTransform = 'translateX(' + x + 'px) translateY(' + y + 'px)' + ' translateZ(0)';

}
ready
translate + z
var x = y = 0;
for (var i = 100; i--;) {
 x = i;
 y = 0;

 style.WebkitTransform = 'translate(' + x + 'px, ' + y + 'px)' + ' translateZ(0)';

}
ready

Revisions

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