5

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

Need structure for motion vector. Its pretty much an object with 2 chars:

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

This

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

is much faster on safari than this:

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

But the opposite on the other browsers.

Why...?

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

Edit the pseudo struct is faster on ios, its just the desktop browser.

Pankaj Bisht
  • 986
  • 1
  • 8
  • 27
brianxautumn
  • 1,162
  • 8
  • 21
  • Safari doesn't use V8, does it? – Pointy Oct 26 '16 at 23:58
  • No I don't think so – brianxautumn Oct 26 '16 at 23:59
  • 2
    My guess would be that the conversion from 8-bit native byte to 64-bit floating point to do the math (and the back again for storage) might have something to do with it. – Pointy Oct 27 '16 at 04:10
  • WebKit uses JavaScriptCore as its engine. You could try to look for documents on the internal workings. Some documents can be found here https://github.com/a0viedo/demystifying-js-engines . But there are many more that can be found by googling for javascriptcore internals. – ZiggZagg Apr 15 '18 at 19:34

0 Answers0