Skip to content
This repository was archived by the owner on Mar 11, 2021. It is now read-only.

Understanding Statistics

Brandon Risell edited this page Apr 30, 2017 · 7 revisions

In CocosSharp we can display certain statistics to the developer so that they can monitor the resources as their game development advances.

Since 1.7

To turn this on you can access the Stats property of your CCGameView and set it's Enabled property.

public static void LoadGame(object sender, EventArgs e)
{
    CCGameView gameView = sender as CCGameView;
    
    gameView.Stats.Enabled = true;
}

Prior to 1.7

To turn this on you can access the DisplayStats from the CCWindow of your ApplicationDelegate.

public override void ApplicationDidFinishLaunching(CCApplication application, CCWindow mainWindow)
{
    mainWindow.DisplayStats = true;
}

- Sample screen shot needed

The meaning of the values

  • 5623459 -- memory consumption in bytes
  • 3 -- garbage collection counter (always 0 when in iOS simulator, see Note below)
  • 015 -- number of draw calls
  • 0.003 -- time it took to update the frame
  • 0.356 -- time it took to draw the frame
  • 60.0 -- frames per second
  1. Memory consumption in bytes of the application

  2. How many times the garbage collection counter has been triggered to clean up objects.

  3. The Draw Call number is the number of draw calls. Typically each node that renders something on the screen (sprites, labels, particle systems, etc) increases that number by one. If you use a CCSpriteBatchNode and add 100 sprites to it, it will increase the draw call only by 1. Draw calls are expensive, so it is very important to keep that number down.

  • To reduce the number of draw calls you, depending on the game's complexity and assuming it is well optimized to reduce draw calls the developer can for instance create a texture atlas out of their sprite images (use TexturePacker, Zwoptex, SpriteHelper) in order to use CCSpriteBatchNode so you could reduce the number of draw calls to one.
  1. The time it took to render a frame is in milliseconds.

  2. The time it took to draw a new frame. Since you need to draw a new frame every 0.016666666 seconds in order to achieve 60 frames per second (1/60 = 0,0166...) this number can tell you how close your game is to dropping below 60 fps.

  3. The last number is the number of frames per second. This value, like the previous one, is averaged over several frames so that it doesn't fluctuate as much (makes it hard to read).

  • The time it took to draw and FPS can become misleading when comparing to frame rates below 15 frames per second

Note There is a special case for Xamarin iOS monotouch on emulator where they aggresively call garbage collection themselves on the simulator. This should not affect the devices though. So we check if we are running on a Device and only update the counters if we are.

(parts of the description from Stack Overflow comment by Steffen Itterheim)

Clone this wiki locally