UDN
Search public documentation:
ProfilingBasics
日本語訳
中国翻译
한국어
Interested in the Unreal Engine?
Visit the Unreal Technology site.
Looking for jobs and company info?
Check out the Epic games site.
Questions about support via UDN?
Contact the UDN Staff
中国翻译
한국어
Interested in the Unreal Engine?
Visit the Unreal Technology site.
Looking for jobs and company info?
Check out the Epic games site.
Questions about support via UDN?
Contact the UDN Staff
UE3 Home > Performance, Profiling, and Optimization > Basic Profiling and Optimization Techniques
Basic Profiling and Optimization Techniques
Overview
STAT Commands
Preparing the Profiling Environment
- First, make sure to always have STAT UNIT up while you're running the game
- Make sure to turn off any log spam or debug code that will taint performance results
- Turn off garbage collection verification because it will contribute to hitching
- Disable VSync so you can identify bottlenecks, even on fast frames
STAT UNIT
Use the STAT UNIT command to determine where your frame time bottleneck is. STAT UNIT will toggle an on-screen HUD that displays Frame time, Game thread time, Render thread (Draw) time and GPU time (if possible.) This is an invaluable first step for tracking down performance problems -- you should pretty much always have this turned on. Also, you an use the STAT FPS command to display frame rate and frame time on the screen.Turn off garbage collection verification
While working on performance you should always have GC Verification turned off, otherwise you can expect massive hitching in Release builds at least every 30 seconds or so. You can do this using one of the following methods:- Pass the -NoVerifyGC command-line argument.
Disabling VSync
For best results you may want to turn off VSync (waits for vertical retrace before presenting frames.) Otherwise the frame time will be padded to the game's refresh rate, which can make it more difficult to get an accurate picture. To turn off VSync:- Pass the -NoVSync command-line option to the game.
- Or, enable the "No VSync" checkbox in the Game tab of Unreal Frontend.
Using STAT SLOW
You can use the STAT SLOW command to help find performance spikes. It can help you narrow down hitches by reporting any cycle stats that run longer than a specific duration in a frame (10 ms by default.) Stats that run slowly will be displayed on the HUD for a little while, making it easier to correlate the spike with game behavior on screen. To use, enter STAT SLOW in the console with the optional arguments what the threshold is in seconds (so 0.01 for 10 ms) and how long to render the stat once it has spiked once. The default is 10 seconds. Example:STAT SLOW 0.01 10
This will render all cycle stats that have been > 10 ms in the last 10 seconds.
Tips and Tricks
Just Turn It Off
Games normally have a number of features that are exciting to see but are a bit expensive. That is normally fine except when you start doing those expensive things a lot OR when you have a complex scene where those expensive things are causing the scene to be slow. You can spend hours optimizing and getting 20-40% improvements which may not even make the scene fast enough. The other way is to just turn that functionality off!! This is a great strategy for things that may not be noticed when there is lots of carnage occurring or for things that are far in the distance. Additionally, "just turn it off" is a great technique for doing profiling. Sometimes you need to know if something is going to be worth spending time on optimizing. Just completely turning it off is a great way to say: "If we made this basically free how where are we in terms of our frametime budget". Example Use Cases:- Enemies that are far away from the player don't often need to spawn small blood decals on the ground (e.g. being shot blood effects)
- Enemies that the LD knows the player will never be able to get reach (e.g. enemies on a cliff that is unreachable) don't need to spawn blood pools or drop weapons
- Instead of optimizing a complex SkeletalControl, just don't update it when the owner is not visible
- Instead of simulating cloth when the cloth is not scene, just don't! :-)
Look at a Wall
Quite often code is updating things it really doesn't need to be when they are not visible. Going into a level, turning to face the wall and doing all of the normal profiling that you do is a great way to see if objects are spuriously updating themselves when there is no need. Of course some things need to update themselves when they are not visible, but a lot of objects can get by without constantly updating.Spawn N of a Type
Often in the game you will have a number of enemies of the same type attacking you and the game will be slow. Something is slow with that enemy type! The problem is that the rest of the engine is getting in your way for easily being able to see what is slow. A nice way around that is to get a test level and just spawn N of those enemies in that test level and profile that. It will make it really easy to see where the hot spots are! This is an easy technique to use. Simply do the following:- Place N of the problematic object in a test level
- Profile!