• Register

Wave Engine was born on February 21, 2013 with the exciting mission of developing an engine to help the mobile game developers’ community.

Post tutorial Report RSS Diagnostics

In this tutorial we will learn the use of Wave Engine Diagnostics. With this feature we can know some useful information about our project as: the FPS’s, how long it takes to execute a piece of code, etc.

Posted by on - Basic Client Side Coding

OBJETIVES

In this tutorial we will learn the use of Wave Engine Diagnostics. With this feature we can know some useful information about our project as: the FPS's, how long it takes to execute a piece of code, etc.

CREATE AN EMPTY

Create an empty project using the "WaveEngine Game Project" template and use the name "Diagnostics":
Wave Engine New Project

Now right click on the project "DiagnosticsProject" select the Properties option from the list:
01
In Properties window, select the Build tab and in Conditional compilation symbols set the textbox PROFILE and save changes:
02
Now we can use diagnostics in our project.

Add the next line of code in the CreateScene() method to activate diagnostics feature:
WaveServices.ScreenContextManager.SetDiagnosticsActive(true);

We will need to add the next using:
using WaveEngine.Framework.Diagnostic

Now we can see some diagnostics information like the FPS's int the screen:

Empty WaveEngine project

SHOW TIMER

With Wave Engine Diagnostics we can know how long it takes to execute a piece of code. Just use these lines of code:

Timers.BeginTimer("Cube Behavior Update");
Timers.EndTimer("Cube Behavior Update");

The first line before the piece of code that we
want to check, and the second after the code to check. A very simple example
would be:

protected override void Update(TimeSpan gameTime)
{
Timers.BeginTimer("Cube Behavior Update");
Timers.EndTimer("Cube Behavior Update");
}

This method is in a typical behavior class, the Update() method, and we can see in the screen how long it takes to execute it, in the upper corner right should have appear a new line "Cube Behavior Update":

WaveEngine Timer Diagnostic

We can also check how long it takes to execute
the application initialization. Just add the timer begin in CreateScene()
method, and the timer end in Start() method. With this we are checking how long
it takes to initialize the application, upload assets, etc.

protected override void CreateScene()
{
// Set to true the diagnostic value
WaveServices.ScreenContextManager.SetDiagnosticsActive(true);

// And set the compilation symbol PROFILE in the project
Timers.BeginTimer("Execute Application");

}

protected override void Start()
{
Timers.EndTimer("Execute Application");

}

SHOW LABELS

We can also add labels to our scene; with this we can know the position, speed, angle... of any entity. We only need one line of code:

Labels.Add("Cube position", Transform.Position.ToString());

We add this line in the Update() method of the class we want to check. For example, if we want to check the position of a cube, we need to add the line in the update method of the behavior class, in this case CubeBehavior.cs
Label Diagnostic WaveEngine

FINAL NOTES

Remember that these lines of code will only be executed if PROFILE is set in the project's properties.

If we remove PROFILE those line of code will not be executed.

Created by Carlos Sánchez López.

Comments
SamPl819
SamPl819

Instead ScreenLayers.SetDiagnosticsActive(true)

Reply Good karma Bad karma+1 vote
SamPl819
SamPl819

you need to write it here

Reply Good karma Bad karma+1 vote
SamPl819
SamPl819

ScreenContextManager.SetDiagnosticsActive(true)

Reply Good karma Bad karma+1 vote
Guest
Guest

This comment is currently awaiting admin approval, join now to view.

Post a comment
Sign in or join with:

Only registered members can share their thoughts. So come on! Join the community today (totally free - or sign in with your social account on the right) and join in the conversation.

Follow Report Profile
Contact
Send Message
Homepage
Waveengine.net
Licence
Proprietary
Release date
Engine watch
Follow
Tutorial
Browse
Tutorials
Report
Report
Share
Related Engines
Wave Engine
Wave Engine Proprietary
Related Groups
Wave Corporation
Wave Corporation Developer