Skip to content

Profiling

Cordemans Robin edited this page Aug 4, 2022 · 2 revisions

Introduction

Glory comes with a few tools to profile your application/game. This wiki aims to explain these tools in detail as well as how to add your own samples for profiling.

The Profiler

The profiler window can be opened from Window/Analysis/Profiler.

Sample Graph

The current profiler records a sample frame every 100 milliseconds. Recorded samples are displayed in a graph at the top of the profiler window. Hovering over the graph will show you the total time of that frame for both the graphics and the game thread, clicking a frame will pause recording and select it for closer inspection.

Profiler Graph The sample graph

Sample Inspector

When clicking on a sample you can view more details of the sample in a hierarchy view underneath the graph. It should be noted that sample recording is paused when a sample is being inspecting. In this hierarchy view you can inspect every profiled record within that sample in order to understand which parts are making it take longer than expected. Time duration of each part is shown in ms.

Sample Hierarchy The sample hierarchy

Creating your own samples

The engine can only record samples inside a thread sample, the main threads are the game thread and the graphics thread. To record your own samples in one of these 2 threads you can use Profiler::BeginSample(name) and Profiler::EndSample().

Example:

Profiler::BeginSample("MySample");
// Put your awesome code here!
Profiler::EndSample();

The name supplied with BeginSample is the name that will be used in the profiler window.

You can also nest samples by simply beginning and ending a sample between an existing begin and end.

Example:

Profiler::BeginSample("MyRootSample");
Profiler::BeginSample("MySample1");
// Put your awesome code here!
Profiler::EndSample();
Profiler::BeginSample("MySample2");
// Put even more awesome code here!
Profiler::EndSample();
Profiler::BeginSample("MySample3");
// The epic climax of your awesome code!
Profiler::EndSample();
Profiler::EndSample();

There is no limit to nesting samples.

You may also sample your own threads using Profiler::BeginThread(name) and Profiler::EndThread() the id of the current thread will be used to identify the samples you create on this thread after BeginThread was called. The profiler window currently does not display these, so you will have to make your own editor for this.

Performance Metrics

The editor also comes with a simple performance statistics window displaying some performance metrics from the last rendered frame. Performance metrics can be opened from Window/Analysis/Performance Metrics.

Performance Metrics

Performance metrics window