- In the top navigation bar, click Window → Analysis → Profiler
- (optional) Dock the profiler to the editor
- Enable only the CPU Usage and Memory modules
- Each profiler module provides information about a certain aspect of your game’s performance
- Performance issues related to your code will appear in the CPU Usage and Memory modules
- Run the scene, wait a few seconds, and press the pause button
- The profiler window is split into two sections
- The top shows a set of time-based graphs
- The bottom gives information about the selected frame that’s contextual to the module that is currently in focus
- The profiler window is split into two sections
- Click on a frame in the CPU Usage graph
- By default, the bottom section displays a timeline that represents how long it takes for the CPU to process each frame
- We don’t have any complicated logic so for most of the frame the CPU is just waiting
- To target 60 fps you want to make sure that the CPU can process each frame in less than about 17 milliseconds
- Mouse over one of the spikes in the CPU Usage graph
- You’ll notice that there are spikes that occur consistently in the timeline
- These spikes are caused by overhead from the editor—they won’t appear when your game is deployed and don’t reflect an issue
- Disable everything in the CPU Usage module but Scripts and GarbageCollector
- We want to focus on performance issues that are caused by our script, so let’s disable everything else 8 .Disable everything in the Memory module except for Object Count, GC Used Memory, and GC Allocated in Frame
- Likewise, we’ll only display the information related to our scripts in the Memory module
Last active
September 14, 2021 15:54
-
-
Save charlieamat/c1fe542a8f4d1bd698286e5ff7d8aabb to your computer and use it in GitHub Desktop.
[ta-edu-course-survival-game] Chapter 2 — Unity Performance 101 (1)
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment