Unity profiler tricks

While I don’t have time to properly format and test it, here’s something to share with the community:

There is the ability to export the profiling data to a binary file, which can then be imported again later. This is enabled through scripting via:

function Start () {
Profiler.logFile = “mylog.log”;
Profiler.enableBinaryLog = true; // writes to “mylog.log.data”
Profiler.enabled = true;
}

and reimported into the profiler:

Profiler.AddFramesFromFile (“mylog.log”);

The API to access the profiler frame data in script is exposed in

UnityEditorInternal.ProfilerDriver

Not documented but completely public in the UnityEditorInternal namespace.

Other useful API:

Profiler.BeginSample („MyCode”);
Profiler.EndSample ();

Profiler.GetRuntimeMemorySize (o : Object) : int

Tagged with: ,
Posted in Blackmagic
  • http://anastasiadevana.com/ Anastasia Devana

    Nice! Thank you so much for the tip about UnityEditorInternal.ProfilerDriver. Have been looking forever on how to access profiler stats via script! :)

My Twitter is @iwozik

Other people read