CSS 2d/3d transform matrix vs left/top positioning (v125)

Revision 125 of this benchmark created by Rafael Grillo on


Description

Modified the code to use the matrix and matrix3d functions instead of css translate/translate3d

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
matrix3d
var x = 0,
    y = 0;
for (var i = 100; i--;) {
  x = i;
  y = i * 5;
  var transform = 'matrix3d(1,0,0,0,0,1,0,0,0,0,1,0,' + x + ',' + y + ',0,1)';
  style.MozTransform = transform;
  style.WebkitTransform = transform;
  style.OTransform = transform;
  style.msTransform = transform;
}
ready
matrix
var x = 0,
    y = 0;
for (var i = 100; i--;) {
  x = i;
  y = i * 5;
  var transform = 'matrix(1,0,0,1,' + x + ',' + y + ')';
  style.MozTransform = transform;
  style.WebkitTransform = transform;
  style.OTransform = transform
  style.msTransform = transform;
}
ready
css left/top
var x = 0,
    y = 0;
for (var i = 100; i--;) {
  x = i;
  y = i * 5;
  style.left = x + 'px';
  style.top = y + 'px';
}
ready

Revisions

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