C# Class Nez.Analysis.TimeRuler

Realtime CPU measuring tool
You can visually find bottle neck, and know how much you can put more CPU jobs by using this tool. Because of this is real time profile, you can find glitches in the game too. TimeRuler provide the following features: * Up to 8 bars (Configurable) * Change colors for each markers * Marker logging. * It won't even generate BeginMark/EndMark method calls when you got rid of the DEBUG constant. * It supports up to 32 (Configurable) nested BeginMark method calls. * Multithreaded safe * Automatically changes display frames based on frame duration. How to use: call timerRuler.StartFrame in top of the Game.Update method. Then, surround the code that you want measure by BeginMark and EndMark. timeRuler.BeginMark( "Update", Color.Blue ); // process that you want to measure. timerRuler.EndMark( "Update" ); Also, you can specify bar index of marker (default value is 0) timeRuler.BeginMark( 1, "Update", Color.Blue ); All profiling methods has CondionalAttribute with "DEBUG". If you not specified "DEBUG" constant, it doesn't even generate method calls for BeginMark/EndMark. So, don't forget remove "DEBUG" constant when you release your game.
Show file Open project: prime31/Nez Class Usage Examples

Public Properties

Property Type Description
enabled bool
instance TimeRuler
showLog bool
targetSampleFrames int
width int

Public Methods

Method Description
getAverageTime ( int barIndex, string markerName ) : float

Get average time of given bar index and marker name.

Private Methods

Method Description
TimeRuler ( ) : System
beginMark ( int barIndex, string markerName, Color color ) : void
beginMark ( string markerName, Color color ) : void
endMark ( int barIndex, string markerName ) : void
endMark ( string markerName ) : void
onGraphicsDeviceReset ( ) : void
render ( ) : void
render ( Vector2 position, int width ) : void
resetLog ( ) : void
startFrame ( ) : void
toggleTimeRuler ( ) : void

Method Details

getAverageTime() public method

Get average time of given bar index and marker name.
public getAverageTime ( int barIndex, string markerName ) : float
barIndex int Index of bar
markerName string name of marker
return float

Property Details

enabled public property

public bool enabled
return bool

instance public static property

public static TimeRuler,Nez.Analysis instance
return TimeRuler

showLog public property

Gets/Set log display or no.
public bool showLog
return bool

targetSampleFrames public property

Gets/Sets target sample frames.
public int targetSampleFrames
return int

width public property

Gets/Sets timer ruler width.
public int width
return int