translate3d vs translate vs css left/top vs css margin (v69)

Revision 69 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 style = elem.style;
</script>

Test runner

Ready to run.

Testing in
TestOps/sec
translate3d
var x = 0,
  t = '';

for (var i = 200; i--;) {
  x = i * 5;
  t = 'translate3d( 0px, ' + x + 'px, 0)';
  style.WebkitTransform = t;
  style.MozTransform = t;
  style.OTransform = t;
  style.msTransform = t;
  style.transform = t;
}
ready
translate
var x = 0,
  t = '';

for (var i = 200; i--;) {
  x = i * 5;
  t = 'translate( 0px, ' + x + 'px)';
  style.WebkitTransform = t;
  style.MozTransform = t;
  style.OTransform = t;
  style.msTransform = t;
  style.transform = t;
}
ready
left
var x = 0,
  t = '';

for (var i = 200; i--;) {
  x = i * 5;
  t = x + 'px';
  style.top = t;
}
ready
margin
var x = 0,
  t = '';

for (var i = 200; i--;) {
  x = i * 5;
  t = x + 'px';
  style.marginTop = t;
}
ready

Revisions

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