Using the Unity Profiler
Unity Profiler Course
The Unity Profiler is a tool you can use to get performance information about your application. You can connect it to devices on your network or devices connected to your machine to test how your application runs on your intended release platform. You can also run it in the Editor to get an overview of resource allocation while you’re developing your application.
The Profiler gathers and displays data on the performance of your application in areas such as the CPU, memory, renderer, audio, UI, etc. It’s a useful tool to identify areas for performance improvement in your application, and iterate on those areas.
To access unity Profiler, you need to go to Windows > Analysis > Profiler
To get in-depth information on frame spikes, be sure to set Deep Profile to Active as it draws information on frames as deep as specific function call.
Also set the information to Hierarchy to get easy to understand information. Inside it, you need to mainly focus on CPU consumption and GC alloc which is a garbage the CPU needs to clear before going to next frame which is the reason for spikes. Here, ignore the Editor loop which is the tool you are using to draw information.
To get the best information, build the app as an development build while setting Autoconnect Profiler to Active which will allow us to get information without the influence of editor and get more accurate information.