# Instrument all function calls

> Enable deep profiling to capture detailed function call information.

The Profiler only profiles code timings that are explicitly wrapped in [Profiler markers](/engine/7000.0/manual/analysis/profiler/markers.md). This includes the first call stack depth of invocations from Unity's native code into your scripting code, such as `MonoBehaviour.Start`, `MonoBehaviour.Update`, or similar methods.

The only samples you can visualize as child samples of your scripting code are those that call back into Unity’s API, if that API is instrumented, or any of your own code which has explicit Profiler marker instrumentation. Most API calls that carry a performance overhead are instrumented. For example, accessing the main Camera through the `Camera.main` API registers as a `FindMainCamera` sample.

## Deep profiling

If you want to get data about all function calls to find out where your code impacts on your application’s performance, you can use the **Deep Profile** setting. When you enable the Deep Profile setting, the Profiler injects profiler instrumentation into all your script methods to record all function calls, including at least the first call stack depth into any Unity API.

Deep profiling works best for small applications with simple scripting. This is because deep profiling adds memory cost to every managed method call. As a result, your application runs slower whether the Profiler is recording or not. Processing and visualizing a Profiler capture with **Deep Profile** enabled also uses a lot of memory. If you use deep profiling with a larger application, then Unity might run slowly or run out of memory.

### Enabling Deep Profiling

You can enable Deep Profiling if you're collecting performance data from a connected application, or if you're collecting data in the Unity Editor.

To enable Deep Profiling for a built application:

1. Open the **Build Profiles** window (**File** > **Build Profiles**)
2. Select your application’s target platform
3. Enable the Development Build setting
4. Enable **Deep Profile**.

When you start a profiling session the Profiler instruments every managed method, including project scripts, Unity engine code, and System libraries.

To enable deep profiling when you collect data in the Editor:

1. Open the Profiler window (**Window** > **Analysis** > **Profiler**)
2. Select **Deep Profile** from the [Profiler toolbar](/engine/7000.0/manual/analysis/profiler/window.md).

When you start a profiling session the Profiler reloads your scripts and instruments your project scripts and Unity's managed code.

To instrument System libraries, do the following:

1. Open the dropdown next to **Deep Profile**.
2. Select the **Instrument Everything** checkbox.

This prompts you to restart the Editor with the [`-deepprofiling`](/engine/7000.0/manual/unity-editor/command-line-arguments/editor.md) command line argument added. When you disable **Instrument Everything**, a prompt appearts to restart the Editor with `-deepprofiling` removed.

To start the Editor with `-deepprofiling` enabled, add it to the command line. This enables the **Instrument Everything** setting by default and warning icon appears next to **Deep Profile** to indicate that all managed code stays instrumented for the rest of the session.

> **Note:**
>
> When you instrument System libraries, Unity disables precompiled code and inlining for all managed code for the rest of the session, even if you disable **Instrument Everything**.

## Additional resources

* [Build Profiles Profile settings reference](/engine/7000.0/manual/analysis/profiler/profiling-applications/build-settings-reference.md)
* [Profiler markers introduction](/engine/7000.0/manual/analysis/profiler/markers.md)
* [Introduction to collecting performance data](/engine/7000.0/manual/analysis/profiler/profiling-applications/profiling-collect-data-introduction.md)
