Is it somehow possible to save the Profiler Details to a file to do statistics on it? I need to do some performance measurements especially on GPU usage. Therefore I need to have a longer sequence of values saved to do some calculation on it.
It looks like you can only export the Fps per frame (sounds kind of wired) to a file via
Profiler.logFile = "testlogfile.txt";
But it appears that this is the only data that you can get from the profiler.
Ok, this is a big deficiency, since details over 300 frames can be inspected directly during runtime. I believe it would be no big effort to provide a save button.
You can save the output of the profiler (binary data and frames per second) in seperate files. It worked for me on iOS.
// write FPS to "profilerLog.txt"
// persistentDataPath, because dataPath seems to be readOnly under iOS
Profiler.logFile = Application.persistentDataPath + "/profilerLog.txt";
// write Profiler Data to "profilerLog.txt.data"
Profiler.enableBinaryLog = true;
Profiler.enabled = true;
If you attach the written data file to the asset folder of your unity project, you can display the data in the profiler:
Profiler.AddFramesFromFile(Application.dataPath + "/profilerLog.txt");
How can you store the profiler data IN THE EDITOR to a file and then reload it ?
Still there’s no way to resolve the binary data file the extract specific statistics?
It would be very useful when you want to get the average values of some statistics throughout the time
I don’t see GPU data when I record data from the player to a log file and load it back into editor. I see CPU and most of the other stats, including Rendering, but not GPU Usage.
With a look into the ProfilerWindow class on the decompiled unity code (which you may find online) you can easily write a script that exports the data you need.
The script might look like this
using UnityEditor;
using UnityEditorInternal;
var firstFrameIndex = ProfilerDriver.firstFrameIndex;
var lastFrameIndex = ProfilerDriver.lastFrameIndex;
var profilerSortColumn = ProfilerColumn.TotalTime;
var viewType = ProfilerViewType.Hierarchy;
var profilerData = new ProfilerData();
for (int frameIndex = firstFrameIndex; frameIndex <= lastFrameIndex; ++frameIndex)
{
var property = new ProfilerProperty();
property.SetRoot(frameIndex, profilerSortColumn, viewType);
property.onlyShowGPUSamples = false;
bool enterChildren = true;
while (property.Next(enterChildren))
{
// get all the desired ProfilerColumn
var name = property.GetColumn(ProfilerColumn.FunctionName);
var totalTime = property.GetColumn(ProfilerColumn.TotalTime);
// store values somewhere
}
property.Cleanup();
}
If you want, you can use this script that allows you to export the data as a JSON file and provides also some useful stats when you are profiling.
https://github.com/steve3003/unity-profiler-data-exporter