There isn’t a clearer and more immediate indication of the overall performance of your project than its framerate. Although it doesn’t provide a lot of context as to the how or why your game might be underperforming, keeping an eye on your fps allows you to catch any strange behaviour before your project gets too far along and the optimization process becomes that much harder to address.
The simplest way to display your Unreal project’s framerate is by selecting the ‘Show FPS’ option within the viewport’s hamburger menu, or by using the shortcut Ctrl+Shift+H. You could also use the ‘stat fps’ console command, which achieves the same thing.
Unreal provides a wide range of performance-related console commands that display useful engine statistics to help you optimize your game. Let’s have take a look into a few of these interesting windows into the engine’s vitals, explore how they can be interpreted, and discuss why all of this is so important.
Toggle the debug FPS Display via the viewport menu, or by pressing Ctrl+Shift+H.
Toggling the FPS Display
Your fps readout is going to be your faithful companion for the lifecycle of your project and it’s important to get into the habit of checking it regularly as you add new content.
Whether you’re using Unreal 4 or 5, the fastest way to see your fps within the Editor is to press the Ctrl+Shift+H shortcut, or select Show FPS from the hamburger menu found in the top left of your viewport. This will display your current frames per second as well as the time in milliseconds it took to render the previous frame.
Unfortunately this method won’t work in a packaged build or in PIE, as in this case the viewport menus are disabled. Instead, to toggle the FPS Display while your game is running you’ll need to enter stat fps as a console command.
Console commands (also known as exec commands) can be accessed by pressing the tilde (~) key that sits to the left of the 1 on your keyboard. The console may appear in a few different places depending on how you’re running your game.
Fortunately you won’t need to do this every time you hit play as the state of the debug ‘stat’ readouts will persist until you restart the engine.
Setting up a quick shortcut using an Execute Console Command Node in your Pawn or Player Controller (or perhaps Game Mode if you’re just looking to run this on the server) is a quick and easy way to toggle the FPS Display mid-game with a single button press.
If you’re looking to just be able to see fps data from within the Editor, you can enable the Titlebar Statistics via the Editor Preferences. Just look for the Show Frame Rate and Memory checkbox within the Performance section. Check out this tip from Unreal Directive for further details!
Interpreting the FPS Display
If your game is running at all well your FPS Display is probably updating at a speed so blindingly fast that it can sometimes be a bit difficult to read. To help with legibility the engine will automatically tint the text based on a few simple thresholds.
|Green||Greater than/equal to 29.5|
|Yellow||Less than 29.5, greater than 20|
|Red||Less than/equal to 20|
You may have noticed that these colors are calibrated to the industry standard of 30fps most commonly found on consoles. Some people (myself included) would argue that in most cases a framerate of 30 is a minimum viable value rather than a standard to aim for, but unfortunately as far as I’m aware it’s not possible to tweak these color bands to better suit more aggressive performance targets.
If you’re looking to recalibrate your FPS Display to account for higher values like 60 or 120, you’ll need to create your own. This isn’t a challenging proposition but it’s not something we’ll dive into in this article. My tutorial on creating a more configurable FPS Display will be released in the coming weeks. Stay tuned!
Although your framerate is an excellent gauge of the moment-to-moment performance of your game, it’s also the last link in a long chain of information and a single value can only tell you so much about what’s happening behind the scenes. To properly unpack the how and the why you’ll need some additional information. This is where the inbuilt ‘stat’ console commands come in handy.
You can also access these commands within the Editor via the viewport hamburger menu, and this is a really useful way to see which ones are available. The tooltips will often (but not always) explain provide further context as to how they work.
There are a lot of stat commands, and they can get really specific about what performance information they display. I’ve compiled a short list of those I find most useful, ordered by their informational complexity. I’ve also tried to include a brief description of what each will tell you about your game’s performance. Most of these can be used at the same time and will not overlap/interfere with each other.
The same as pressing Ctrl+Shift+H, this command displays your game’s current framerate in frames per second as well as the time in milliseconds (ms) that it took for the previous frame to be generated. This is a common and unobtrusive way to gauge the performance of your game but doesn’t provide much context.
The stat unit command adds an additional readout immediately beneath your FPS Display that provides more information on previous frame time.
The stat fps readout (left) and with stat unit also enabled.
The Frame value at the top is the total time it took for the previous frame to render, the same information that is displayed by stat fps. The other values show the render time for the Game and Draw (rendering) threads, as well as a bunch of other useful information.
Check out Unreal Directive’s breakdown of Stat Unit for a succinct explanation of these values and what each can tell us about our game’s performance. They have done a great job of breaking down each value and what they represent.
Stat unit is a super useful command when you’re looking to narrow down why your game might be running poorly, as you’ll be able to see where the bulk of the frame time is being consumed. For example, if your Draw value is taking up the bulk of that time then your game is likely bottlenecked by the render thread.
If you’re interested in learning more about how to decipher these values, Bob Tellez did a fantastic write up for Unreal Engine’s blog section which you can read here.
The stat unitgraph command is similar to stat unit, except that it also adds a graph in the bottom left of your viewport that plots these values over time, making it easier to identify spikes in your frame time.
It’s important to note that the information presented by stat fps, stat unit and stat unitgraph is filtered, with the engine providing the average value over a period of approximately 10 frames. If you want to see the unfiltered information you should use the command stat raw.
Other stat commands
It’s worth repeating that there are a lot of stat commands that cover a huge range of different engine features. The ones we’ve looked at today have all been from within the Engine category, but there are many more that offer different approaches to monitoring the health of your project.
Some others you may want to check out include:
- stat engine (a more in-depth version of stat unit)
- stat gpu (GPU statistics)
- stat cpuload (CPU utilization)
- stat streaming (Texture streaming information – I wrote a whole guide on how to use this one!)
Sharing framerate information with your players
There may come a time where you want to share performance data with your players, or perhaps you’d just like to view the FPS Display within a shipping build where debug console commands and their associated screen messages have all been disabled.
To achieve this you’ll need to create a Widget that reads and then interprets the time between each rendered frame. Luckily I’m in the process of writing a tutorial to do exactly this, so please check back again in a week or so!
Improving your framerate
The love/hate relationship with the framerate counter is a mainstay of the game development experience. If you’ve toggled your FPS Display on and you’ve discovered some nasty surprises it might be time to look at further optimizing your project.
Unfortunately a breakdown of how to optimize your game and reduce your framerate is well beyond the scope of this article, but you’re in luck. There is no shortage of both written and video tutorials on the subject of optimization. Here are a few I found to be useful primers to jump into the topic.