To profile your code at runtime using the release version
of the runtime, without an external tool, you can use the Stats
class developed by mr. doob from the Flash community. You can download
the Stats class at the following address:
https://github.com/mrdoob/Hi-ReS-Stats
.
The Stats class allows you to track the following things:
-
Frames rendered per second (the higher the number, the better).
-
Milliseconds used to render a frame (the lower number, the
better).
-
The amount of memory the code is using. If it increases on
each frame, it is possible that your application has a memory leak.
It is important to investigate the possible memory leak.
-
The maximum amount of memory the application used.
Once downloaded, the Stats class can be used with the following
compact code:
import net.hires.debug.*;
addChild( new Stats() );
By using conditional compilation in Adobe® Flash® Professional or Flash Builder, you can
enable the Stats object:
CONFIG::DEBUG
{
import net.hires.debug.*;
addChild( new Stats() );
}
By switching the value of the
DEBUG
constant,
you can enable or disable the compilation of the Stats object. The
same approach can be used to replace any code logic that you do
not want to be compiled in your application.