13

I have 3 numbers on the bottom left part of the screen on my Cocos2D 2.0 project:

82
0.016
60.0

60 is probably FPS and what about the other two? As I remember, previous versions of Cocos had just the FPS number.

Any clues? thanks

Duck
  • 34,902
  • 47
  • 248
  • 470
  • The top number I believe is the # of sprites. The middle I am not sure about. – SimplyKiwi Jun 04 '12 at 23:28
  • it makes sense... 82 sprites. Right. If this helps, the middle number oscillates between 0.016 and 0.017... – Duck Jun 04 '12 at 23:30
  • If I remember correctly, that is milliseconds for something. Maybe the FPS's milliseconds? But the middle does not matter that much, only the top and bottom really matter. – SimplyKiwi Jun 04 '12 at 23:37
  • OK. thanks. Post your comments as answer so I can accept... – Duck Jun 05 '12 at 00:00

2 Answers2

37
82    <-- number of draw calls
0.016 <-- time it took to render the frame, here: 1.0/60.0 = 60 fps
60.0  <-- frames per second

The first number (82) is the number of draw calls (which is fairly high). Typically each node that renders something on the screen (sprites, labels, particle fx, etc) increases that number by one. Draw calls are expensive, so it is very important to keep that number down. One way to do so is by batching draw calls - cocos2d v3 does this automatically.

The time it took to render a frame, in seconds. Since you need to draw a new frame every 0.016666666 seconds in order to achieve 60 frames per second (1/60 = 0,0166…) it's just the inverse of the framerate.

The last number is the number of frames per second aka framerate aka fps. This value, like the previous one, is averaged over several frames so that it doesn't fluctuate as much.

Note that iOS devices always have VSynch (vertical synchronization) on. A game can render a frame every 0.0166 seconds - if every frame takes 0.017 seconds to compute, the framerate is effectively halved to 30 fps. You can only have fps in concrete steps: 60, 30, 20, 15, 12, 10 ...

Since the fps display is averaged over a couple frames it hides this fact. So if the display stats show 45 fps would be a sequence of frames where every other frame took longer than 0.0166 seconds. In fps numbers the individual fps of most recent frames would have been: 60, 30, 60, 30, 60, 30.

CodeSmile
  • 64,284
  • 20
  • 132
  • 217
  • great thanks. In fact this app is not very optimized right now, but it will be. Optimization is generally the last thing I do. Thanks for the explanations. – Duck Jun 07 '12 at 19:28
2

The top number is the number of sprites in your CCLayer, etc..

The middle is the FPS's milliseconds.

The bottom is of course your FPS! :)

SimplyKiwi
  • 12,376
  • 22
  • 105
  • 191
  • 1
    The top number is the number of draw calls, not the number of sprites. – CodeSmile Jun 07 '12 at 13:40
  • @LearnCocos2D What's the difference between one and the other? – toasted_flakes Apr 06 '13 at 10:45
  • each drawn object creates a draw call ie every label, sprite, every particlesystem, every batch node adds 1 draw call. Draw call is a state change in opengl, and changing states (ie drawing from a different texture) is an expensive operation. More so the larger the texture is. – CodeSmile Apr 06 '13 at 11:32