On Thu, Mar 21, 2013 at 4:47 PM, Ben Adams <
thundercat@illyriad.co.uk> wrote:
>
>> >>> On Thu, Mar 21, 2013 at 2:40 PM, Florian Bösch <
pyalot@gmail.com>
>> >>> wrote:
>> >>>>
>> >>>> On Thu, Mar 21, 2013 at 10:16 PM, Rik Cabanier <
cabanier@gmail.com>
>> >>>> wrote:
>> >>>>>
>> >>>>> Which one is faster:
>> >>>>>
>> >>>>> element.style.transform =
>> >>>>> window.getComputedStyle(element).transformMatrix.rotateBy(45); // 1
>> >>>>> temporary object. all calculations on c++ side
>> >>>>>
>> >>>>> or
>> >>>>>
>> >>>>> ... make sure some js library is loaded
>> >>>>> element.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 side
>> >>>>
>> >>>>
>> >>>> Neither, this one is faster:
>> >>>>
>> >>>> mat4Rotate(window.getComputedStyle(element).transform, 45,
>> >>>> element.style.transform)
>> >>>> ^
>> >>>> source
>> >>>> ^a ^ target
>> >>>>
>> >>>> We'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.
>> >>>
>>
>> There is more work to be done. In Chrome, the typed array
>> implementation is being moved from the browser into the _javascript_
>> engine. This will both speed up typed array allocation, which is
>> currently quite slow in Chrome, as well as track the ECMAScript 6
>> specification, which incorporates typed arrays into the language.
>>
>
> Does this mean you may be able to do something like:
>
>
> var v1 = new Float32Array([1,2,3,4]);
> var v2 = new Float32Array([4,3,2,1]);
>
> v1 *= v2;
> // v1 == [4.0,6.0,6.0,4.0]
> v2 += v1;
> // v1 == [8.0,9.0,8.0,5.0]
>
> Then the if/maybe of SSE/etc interop could, if desired, be handled behind
> the scenes when available. And I'm sure then people could write these high
> performance _javascript_ matrix libraries