Profiling

Verificado com a versão: 2018.1

-

Dificuldade: Avançado

Profilers are essential tools for determining memory and performance bottlenecks. Unity comes with integrated tools and an instrumentation profiler (tracer) that provide a quick overview of the state of a Project. This guide features the different profiling tools that ship with Unity, their uses, and important caveats. For additional tips and tricks, see the Profiler documentation.

To choose the right profiling tool for your application, it’s important to understand the difference between profiling, sampling and tracing:

Profiling — The process of collecting performance data on the target. A profiling session in most tools typically includes sampling and tracing.

Sampling — The process of periodically stopping the application under investigation during the profiling session (a profile). Sampling typically involves collecting backtraces (call stacks of active threads), which helps to understand statistically how much time each function takes. Additionally, it is possible to sample hardware counters. This process is inherently imprecise when the Profiler collects a low number of samples.

Tracing/Instrumentation — The process of collecting precise information about various activities happening in the profile or the system. For example, the Profiler may trace a call to the profile of a specific library function and record the exact duration and timestamps.

Samplers are more predominant than tracers, which often makes it difficult to obtain accurate timing information due to the lack of an advanced tracer.

The goal of this guide is to fit you with the necessary knowledge to profile and optimize applications made with Unity. This guide covers the following areas:

"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.