valueerror Posted September 21, 2014 Share Posted September 21, 2014 i've attached a screenshot of a javascript cpu profile i ran in chrome and i would like to know more about how to use it / what those numbers say.. my game is pretty heavy on mobile devices and i don't exactly know what to do about it because i already changed so much to get my almost 60fps and now i'm back at 40fps on a nexus 7 2013 what does this "window.requestAnimationFrame.forceSetTimeOut._onLoop" mean? it seems to eat all eft the cpu in some way.. does this mean the animation of the sprites eat up my cpu? so many questions in my head.. .thx in advance! Link to comment Share on other sites More sharing options...
xerver Posted September 22, 2014 Share Posted September 22, 2014 https://github.com/photonstorm/phaser/blob/master/src/system/RequestAnimationFrame.js That is the main loop of the Phaser game implementation. Without an exported snapshot, or a running sample I can't really say anymore. I can't tell how you sorted the data, or what the timeline actually looks like :/ Link to comment Share on other sites More sharing options...
valueerror Posted September 22, 2014 Author Share Posted September 22, 2014 well.. me neither.. i guess thats the problem.. could you please explain what you mean by "how i sorted the data" ? what data? what timeline? how would i do this right to be able to figure out where in my code the bottlenecks are? could you point me to some online docs about this ? is this cpu profile normal for a game like "angry birds" (i've got similar compexity) assets flying around, physics, explosions, particles, spring and revolute constraints, a lot of sounds and at least 2-4 animations running all the time, tweens and a lot of timerevents Link to comment Share on other sites More sharing options...
Robske Posted September 22, 2014 Share Posted September 22, 2014 The CPU consumed is non-idle CPU only. It's not the exact time the CPU spends in total, but just on the handling of all updates.This is normal, since RAF occurs frequently. When the system is nog handling the RAF, this time is 'idle' and not logged. Hope this helps. Link to comment Share on other sites More sharing options...
valueerror Posted September 22, 2014 Author Share Posted September 22, 2014 a little bit.. thx. do i have any influence on the RAF ? what makes it consume the cpu.. is there a way to monitor the code i wrote? -- find out which functions are called all the time (maybe too often - more than needed) or which funcions eat the cpu? Link to comment Share on other sites More sharing options...
Robske Posted September 22, 2014 Share Posted September 22, 2014 RAF is the update loop in Phaser. It will consume the CPU, since that is where all the heavy lifting takes place. This method is called by the browser in order to instruct the system to update the screen in response to a 'screen refresh'. If you look closely in the call-tree, you can clearly see where time is spent. The time reported always includes children, so as you can see, drawImage consumes about 5% of the total time. You do not really need to know about this all, but if you are interested, some more infor about this:https://developer.mozilla.org/en-US/docs/Web/API/window.requestAnimationFrameandhttp://www.paulirish.com/2011/requestanimationframe-for-smart-animating/ Link to comment Share on other sites More sharing options...
xerver Posted September 22, 2014 Share Posted September 22, 2014 well.. me neither.. i guess thats the problem.. could you please explain what you mean by "how i sorted the data" ? what data? what timeline? how would i do this right to be able to figure out where in my code the bottlenecks are? could you point me to some online docs about this ? is this cpu profile normal for a game like "angry birds" (i've got similar compexity) assets flying around, physics, explosions, particles, spring and revolute constraints, a lot of sounds and at least 2-4 animations running all the time, tweens and a lot of timerevents https://developer.chrome.com/devtools/docs/cpu-profiling You have 71% of your time in idle in that snapshot, the only other things that seems to take up time are drawImage and fillRect. Likely just the core render. It is difficult to tell because of the sort you used on the profile data you shared a screenshot for. The timeline is tab in the chrome dev tools that talks about what the v8 engine is doing. Link to comment Share on other sites More sharing options...
valueerror Posted September 22, 2014 Author Share Posted September 22, 2014 oh.. the timeline seems to be what i was searching for.. still not exactly sure how to find out how i can map what i see to what i coded but i will do further reading on this on the web (thx for the links !) could something like the garbage collection event be responsibe for sudden framedrops?it seems to be responsible for this "shark tooth" reading... (second screenshot) the function call on line 37002 (fixed to camera) that looks like the heaviest thing on every RAF call seems to be because of my ingame menu that is the only thing that's fixed to camera ... this doesn't seem right. thx again Link to comment Share on other sites More sharing options...
valueerror Posted September 22, 2014 Author Share Posted September 22, 2014 oh.. the "sharktooth reading" IS the amount of memory isn't it? so it should drop after the GC runs ^^ Link to comment Share on other sites More sharing options...
xerver Posted September 22, 2014 Share Posted September 22, 2014 Again, screenshots are not very helpful. I need to know what is the problem that makes you want to profile, and either a running example or a dump of your snapshot to investigate. Preferably a running example. Link to comment Share on other sites More sharing options...
valueerror Posted September 23, 2014 Author Share Posted September 23, 2014 thank you for your efforts - i really appreciate that you would be willing to look through my stuff for me.... but i'm actually looking for hints on how to do it on my own(i thought i'd post the screenshots anyway - it wouldn't hurt anybody and you can tell if i'm on the right way) as stated above i want to learn how to do this by myself.. i have sudden framedrops and i would like to find out more about the reason for it... if RAF is the most consuming thing i'm wondering if there is a way to find the lines in my code that are responsible for it.. but i didn't find the time to learn more about this - hopefully on the weekend.. maybe then i'm able to ask better questions thx Link to comment Share on other sites More sharing options...
Recommended Posts