I’ve been trying to use the Visual Studio profiler to measure and analyse CPU performance and usage in my game project. Even though I’ve built the engine from source and the game project in DebugGame (they’re linked in the same solution, too), I get [External Code] for the entirety of the profiler’s output:
I tend to use the built-in profiling that TheJamsh mentioned. You can open the console and use Stat <Stat to view here>. For example, Stat UNIT should give you some real-time info on screen of your current CPU usage among other things.
Yeah it does, but that’s either using the in-editor session frontend (and what’s the point of profiling the CPU if I’m going to run it in the editor? Hello Slate), or potentially dumping out some numbers into a log file - if that’s possible.
The built-in profiler doesn’t give me info on what’s actually taking the time - the biggest offender is my ‘world’. Great, that narrows it down - is it my OpenCL computer, is it my threaded sorting? I need numbers.
(I know I can put a macro in individual functions to profile them. That’s crazy talk).
There’s something about the way UE4 is set up that isn’t allowing for a pretty simple profiler to work. There must be a way to get it to function properly.
For starters, the overhead from ticking Slate in an editor viewport isn’t really going to impact your game performance. It’ll eat up some cycles, for sure, but your game loop performance will remain the same, just with slightly less CPU resources to contend with. The only way a PIE session might alter your critical path is if you somehow have runtime dependencies on editor modules, in which case I would have to salute you for actively going out of your way to sabotage the engine’s module hierarchy.
In any event, if you really want a standalone profiler, the “in-editor” session front-end is anything but. All it does is call the UnrealFrontend from within the editor application instead of on its own. But the front-end is designed to run standalone, or it wouldn’t be much of a front-end. Find the UnrealFrontend executable in Engine/Binaries, or build the UnrealFrontend project if necessary. Run the front-end, then start your game executable with the “-messaging” option. This should allow your engine session to show up in the front-end, and you can proceed with profiling normally.
You should be able to bury down to the individual functions that are taking time in the UE4 profiler, but yeah at the moment you have to write it out to a log I think. It wasn’t working as intended last time I looked at it.