cocos2d/cocos2d-html5

A way of saving the runtime optimizations?

dganzella opened this issue · 4 comments

Hello!

I noticed that the cocos js html5 functions are optimized A LOT as you play the game. The same methods , when called 3 or 4 times, start to run in much less time. Doesnt matter if I'm using Chrome or firefox, desktop or mobile, it always get better as game goes on.

Is there a way to save these runtime optmizations and load them in memory upon opening the game? So the first interactions are not slow.

Thanks.

Danilo

It's the result of great JIT compiler inside all modern JavaScript engines, unfortunately it's a runtime feature only, you can't pre compile the code, because they are supposed to be dynamic (code path, object map, inline functions, etc). The only thing similar is ASM.js and its next generation: WebAssembly, but they are designed for C++ and other compiled languages, they sort of compile the result of such native programs into byte codes (or asm.js format JS codes) that can be run by the browser

i see. Thanks for the explanation.

Is it common practice to simulate the game briefly while 'loading' in order to increase performance? Maybe I can even build asimple input lib to record some steps and then run them before the game starts.

I can only say that it's not a common practice, but you can give it a try if you want.

Thanks once more.

Playing the game by script worked wonders. Its now much faster.

Danilo