skip to Main Content

Profiling Code Blocks

In this post I’m going to show you how you can profile your code blocks in order to identify potential issues and make your game run smoother!

In order expose your code’s performance in the Unreal Engine profiler tool you really need two things:

  • A stat group, which is the “category” of the code you’re profiling in Unreal Engine profiler
  • A cycle stat, which is the name of the code block you’re profiling.

A stat group can contain several different cycle stats. Both stat groups and cycle stats are used to group up statistics in the profiler .

Profiling code

For the sake of this post let’s imagine that we want to profile a function named FindPrimeNumbers. I have created a dummy actor component and inside its header file I added the following property and function:

Inside its source file, right after I’ve included the required header files for my class I declared a stat group and a cycle stat that belongs to the newly created stat group:

Then, I created the following implementation for the FindPrimeNumbers function:

Once I compiled the project, I’ve added that component in the main character and call the FindPrimeNumbers function in each Tick just to showcase the profiler’s result. So, while running the game with the profiler on for a couple of seconds this is the result once I load up the recorded file:

(Click on image to open up in a new tab)

Moreover, when I’m running the game, I can type in the console the command: stat Orfeas and see the realtime impact of that Orfeas-FindPrimeNumbers stat:

stat Orfeas

And that’s an easy way to profile your code using the Unreal Engine profiler tool. Thanks for reading!

This Post Has One Comment

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Back To Top