Toolkit: Unreal Insights & stat Commands
Performance work starts with one question: which thread is the frame waiting for? Unreal runs the game thread (gameplay, Blueprints, animation update), the render thread (preparing draw work), the RHI thread (talking to the graphics API) and the GPU in parallel, each a frame or so behind the previous one. Optimizing the wrong one does nothing for the frame rate.
stat commands: the first look
Open the console (~) during play:
| Command | Shows |
|---|---|
stat fps |
frames per second and frame time |
stat unit |
Frame, Game, Draw (render thread), GPU, RHIT times, plus memory. The longest one is your bottleneck |
stat unitgraph |
the same as a graph over time: spikes vs steady cost |
stat game |
game-thread breakdown: tick time, world tick, navigation, AI |
stat gpu |
GPU time per render pass |
stat scenerendering |
draw calls, primitives, render-thread work |
stat anim, stat ai, stat physics, stat net |
per-system breakdowns |
stat memory, memreport -full |
memory use (memreport writes a file to Saved/Profiling/MemReports) |
stat none |
hide them all |
Read stat unit like this. If Game ≈ Frame, you are game-thread bound: too much ticking, Blueprint logic, animation or physics. If Draw ≈ Frame, too many draw calls or primitives. If GPU ≈ Frame, shading, resolution, Lumen, shadows or post-processing. A quick test for GPU-bound: r.ScreenPercentage 50. If the frame rate jumps, the GPU was the limit.
Warning: Never judge performance in the editor viewport or in a Debug build. Profile a Development or Test packaged build, or at least Standalone Game mode, on the target hardware. The editor adds its own cost to every frame.
Unreal Insights
Unreal Insights is the main profiler: a separate program that records traces from the game or editor and shows a timeline of every thread, with nested timing scopes, counters, memory allocations, asset loading and networking.
Run it:
Engine/Binaries/Win64/UnrealInsights.exe(or, in the editor, Tools → Unreal Insights → Run Unreal Insights, or the Trace widget in the status bar). It starts the trace server that collects traces.Record from the editor: the Trace widget in the bottom-right status bar: choose channels, start/stop, take a snapshot.
Record a packaged or standalone game from the command line:
textArenaGame.exe -trace=default,task,gpu -statnamedevents-trace=picks channels (cpu,gpu,frame,log,bookmark,memalloc,loadtime,net,task…;defaultis a sensible set).-statnamedeventsadds thestatscopes as named events, which gives much more detail on the game thread.-tracehost=<ip>sends to Insights on another machine (a console devkit, a phone).Control from the console:
Trace.Start,Trace.Stop,Trace.File(write toSaved/Profiling/),Trace.Status. For a named marker on the timeline, callTRACE_BOOKMARK(TEXT("Boss phase 2"))in code (headerProfilingDebugging/MiscTrace.h).
Add your own scopes to see your code in the timeline:
#include "ProfilingDebugging/CpuProfilerTrace.h"
void AArenaDirector::UpdateThreatMap()
{
TRACE_CPUPROFILER_EVENT_SCOPE(AArenaDirector::UpdateThreatMap); // appears as a block on the game thread
for (AArenaEnemy* Enemy : Enemies)
{
TRACE_CPUPROFILER_EVENT_SCOPE_STR("ScoreEnemy");
ScoreEnemy(Enemy);
}
}
// Stats that also show in `stat arena`:
DECLARE_STATS_GROUP(TEXT("Arena"), STATGROUP_Arena, STATCAT_Advanced);
DECLARE_CYCLE_STAT(TEXT("Threat map"), STAT_ArenaThreatMap, STATGROUP_Arena);
// … inside a function: SCOPE_CYCLE_COUNTER(STAT_ArenaThreatMap);In the Insights Timing view, select a slow frame (the frame graph at the top), then look at the Timers panel sorted by Exclusive time: that is where the time actually goes, not counting children.
Other tools
| Tool | When |
|---|---|
ProfileGPU (Ctrl+Shift+,) |
a one-frame GPU breakdown, in the editor |
| RenderDoc plugin, PIX (Windows/Xbox), platform GPU tools | deep GPU frame captures |
Memory Insights (-trace=memalloc,callstack,module) |
who allocated what |
| Size Map, Reference Viewer | why an asset is big, and why it's loaded |
obj list class=… |
how many UObjects of a class exist (leaks) |
| Visual Studio / Superluminal / VTune | sampling profilers for native code |
A model of reading stat unit
The engine's frame time is set by the slowest of the pipelined threads, plus waiting. This model takes a few captured frames, finds the bound thread in each, and suggests where to look. The numbers are made up for illustration; the decision logic is the real one.
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
struct FrameStats { double Game, Draw, GPU; };
int main() {
std::cout << std::fixed << std::setprecision(1);
const double budget = 16.7; // 60 FPS
std::vector<std::pair<std::string, FrameStats>> captures = {
{"main menu", {4.1, 3.0, 6.2}},
{"arena, 40 enemies", {19.8, 7.5, 12.3}},
{"arena, big explosion", {9.0, 8.1, 24.6}},
{"open area, foliage", {8.2, 18.9, 15.0}},
};
for (const auto& [name, s] : captures) {
double frame = std::max({s.Game, s.Draw, s.GPU});
std::string bound = frame == s.Game ? "Game" : frame == s.Draw ? "Draw" : "GPU";
std::string hint = bound == "Game" ? "Insights: game thread (Tick, BP, anim, AI)"
: bound == "Draw" ? "draw calls / primitives: stat scenerendering, instancing, HLOD"
: "stat gpu / ProfileGPU: shading, shadows, Lumen, resolution";
std::cout << std::setw(22) << std::left << name << std::right << " Game " << std::setw(4) << s.Game
<< " Draw " << std::setw(4) << s.Draw << " GPU " << std::setw(4) << s.GPU
<< " -> " << (frame <= budget ? "within budget" : bound + "-bound: " + hint) << "\n";
}
}main menu Game 4.1 Draw 3.0 GPU 6.2 -> within budget
arena, 40 enemies Game 19.8 Draw 7.5 GPU 12.3 -> Game-bound: Insights: game thread (Tick, BP, anim, AI)
arena, big explosion Game 9.0 Draw 8.1 GPU 24.6 -> GPU-bound: stat gpu / ProfileGPU: shading, shadows, Lumen, resolution
open area, foliage Game 8.2 Draw 18.9 GPU 15.0 -> Draw-bound: draw calls / primitives: stat scenerendering, instancing, HLOD
Test yourself
stat unit shows Frame 24 ms, Game 9 ms, Draw 8 ms, GPU 24 ms. What should you optimize?
- Blueprint ticks
- GPU work: shading, shadows, Lumen, resolution
- Draw calls
- Networking
What does TRACE_CPUPROFILER_EVENT_SCOPE(Name) do?
- Logs to the output log
- Adds a named timing scope that shows up in Unreal Insights' timeline
- Disables a function in Shipping
- Starts a timer
Why shouldn't you trust frame times measured in the editor viewport?
- The editor runs at a fixed 30 FPS
- The editor adds its own overhead; profile a packaged Development/Test build on target hardware
- Insights doesn't work in the editor
- stat commands are disabled there