Profiler

Author: Michael Garforth

Overview
This C# class gives simple access to simple profiling of code

The script can be placed in an early compilation pass (e.g. Plugins directory) so that it can be used from any language

It has no dependencies besides .NET and Unity

Use
Profile.StartProfile(tag) - Use this to start the profile timer for the specified tag

Profile.EndProfile(tag) - Use this to end the profile of the specified tag

Profile.Reset - Remove all profile data and reset the timer, generally not needed

Profile.PrintResults - Output all profile data to the console, usually called in OnApplicationQuit from one location

Note: Match up every start tag with an end tag, otherwise the timing data will be wrong

Note: The profiler can work across scripts and across scenes by starting the tag in one, and ending it in another. (E.G.: Use: Profile.StartProfile("LoadLevel"); just before Application.LoadLevel(1); and Profile.EndProfile("LoadLevel"); on a script's function Awake; in the new scene.)

Example - TestProfile.cs
Output:

Usage in js
To measure the time a function takes to complete, e.g Start To view the results, you have to select the Profile results in the console

C# - Profile.cs
The script should be named Profile.cs

C# - HRProfile.cs
The script should be named HRProfile.cs and is a modified version of the above script which include ticks for higher resolution.