Why objects are faster than typed arrays in javascript safari

Im working on a Javascript vp8 decoder, everything needs to be as fast as possible for safari in this case, because web browser browsers are the target platform.

A structure is required for the motion vector. Its pretty much an object with 2 characters:

var test = { x:0, y:1 }
var testArray = new Uint8Array(2);

it

test.x = (test.x | 0 + 1) | 0;
test.y = (test.y | 0 + 1) | 0;

much faster on safari than this:

testArray[0] = (testArray[0] + 1) | 0;
testArray[1] = (testArray[1] + 1) | 0;

But vice versa in other browsers.

Why...?

Try jsperf: https://jsperf.com/obj-vs-struct-7

Change pseudo-structure faster on ios, it's just a desktop browser.

+4
source share

No one has answered this question yet.

See similar questions:

:

23498
, ?
2116
, ?
1466
<, <=?

Source: https://habr.com/ru/post/1659007/


All Articles