Skip to content

Instantly share code, notes, and snippets.

@charlieamat
Last active September 14, 2021 15:54
Show Gist options
  • Save charlieamat/c1fe542a8f4d1bd698286e5ff7d8aabb to your computer and use it in GitHub Desktop.
Save charlieamat/c1fe542a8f4d1bd698286e5ff7d8aabb to your computer and use it in GitHub Desktop.
[ta-edu-course-survival-game] Chapter 2 — Unity Performance 101 (1)
  1. In the top navigation bar, click Window → Analysis → Profiler
  2. (optional) Dock the profiler to the editor
  3. 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
  4. 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
  5. 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
  6. 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
  7. 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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment