How to profile performance in Unreal Engine.

Profiling is a critical step in optimizing game performance in Unreal Engine. One way to monitor specific areas of your code is to use stat startfile and stat stopfile commands. These commands help capture profiling data for in-depth analysis, enabling you to identify and fix performance bottlenecks.

Overview

stat startfile and stat stopfile are console commands that generate a profiling data file (.ue4stats) for Unreal Engine’s built-in Unreal Insights tool. You can use them to focus on certain sections of your gameplay or visualize the overall performance over time.

Getting Started with Profiling

Step 1: Launching Your Project

  1. Open your project in Unreal Engine.
  2. Start playing your game either in the editor (PIE) or by launching a standalone game.

 

Step 2: Running the Commands

  1. Press the ~ key (or your project’s console key) to bring up the console command line.
  2. Enter stat startfile to begin recording profiling data.
  3. Play your game normally while the profiling data is being recorded.
  4. Enter stat stopfile when you’re ready to stop profiling.

This generates a .ue4stats file and stores it in the project’s Saved/Profiling/UnrealStats folder.

Step 3: Analyzing the Data with the Session Frontend

Once you have recorded profiling data using stat startfile and stat stopfile, you can use Unreal Engine’s Session Frontend to analyze the results.

  1. Open Session Frontend:

    • In the Unreal Engine editor, open the Session Frontend via “Tools” > “Session Frontend.”
  2. Access Profiler Tab:

    • In the Session Frontend, switch to the “Profiler” tab. This tab allows you to open profiling files for analysis.
  3. Load Profiling Data:

    • Click the “Load” button in the toolbar to browse for the profiling data you generated in Step 2 (located in the Saved/Profiling/UnrealStats folder).
    • Select the appropriate .ue4stats file and click “Open.”
  4. Examine the Data:

    • Frame Graphs: Analyze the graph to see frame times and breakdowns for each frame. You can see spikes indicating where the frame rate drops.
    • CPU Usage: Check how much processing time each game thread uses. This helps identify the heaviest threads that may need optimization.
    • GPU Usage: Understand GPU frame times to identify graphics-related bottlenecks.
    • Memory Usage: See how much memory the game uses over time, which can reveal memory leaks or high usage scenarios.
  5. Inspect Specific Time Ranges:

    • Click and drag on the graphs to zoom in on specific time ranges. This feature lets you focus on particular moments that had performance issues.
  6. Compare Multiple Sessions:

    • You can load multiple profiling sessions in the Profiler to compare how different changes impact performance.

By following these steps and using the Session Frontend effectively, you can gain valuable insights into the performance characteristics of your Unreal Engine project, enabling you to target specific areas for optimization.

 

5/5

Gamechanger plugin for notehighway rhythm games and music visualizers

5/5

Add Text and 2D UMG widgets to Level Sequences

Consider investing in some of our plugins. They might save you some time.  Also helps supports these tutorials.

Instantly get access to our plugins like Blender Curves Importer and UMG Cinematics and more when  you support us on Patreon!

 Join Us On Discord For More Daily Tips!