On Thu, Mar 21, 2013 at 2:40 PM, Florian Bösch <email@example.com> wrote:On Thu, Mar 21, 2013 at 10:16 PM, Rik Cabanier <firstname.lastname@example.org> wrote:Which one is faster:orelement.style.transform = window.getComputedStyle(element).transformMatrix.rotateBy(45); // 1 temporary object. all calculations on c++ side... make sure some js library is loadedelement.style.transform = new MyMatrix(window.getComputedStyle(element).transform).rotateBy(45).getFloatArray(); // 2 (or 3) temporary objects + 6 or 16 (12 or 32?) temporary floats + all calculations on js sideNeither, this one is faster:mat4Rotate(window.getComputedStyle(element).transform, 45, element.style.transform)
^ source ^a ^ targetWe're quite serious when we say temporaries/allocation is a serious problem, seriously, we're not joking. And lengthy discussions on the GC issue have been conducted with only one clear outcome, while things may get better, they will not get perfect.You constructed 2 temporaries there as well as brought in at least 12 floats into the JS VM + you did all the math in js.
If 'element.style.transform' returned a live object, you could just do 'element.style.transform.rotateBy(45)' and have only 1 temporary.