Reputation: 99
The truth is that I have a simple tool to let the game auto run on my android phone. I want to collect the some performance data like Profiler provides, memory, draw calls, each mem allocate on each function and so on. So is there any api or tool to reach that?
Upvotes: 2
Views: 2011
Reputation: 4249
As you already noticed, you can't save from the Profiler more than 300 frames of data.
The only way to save a stream of profiling data, is to write a class and attach the script to every game object in the scene.
using UnityEngine;
using UnityEngine.Profiling;
using System.Collections;
public class ProfilerDataLogger : MonoBehaviour
{
int frameCount = 0;
void Update()
{
if (Input.GetKey(KeyCode.LeftControl) && Input.GetKeyDown(KeyCode.L))
{
StopAllCoroutines();
frameCount = 0;
StartCoroutine(DataLogger());
}
}
IEnumerator DataLogger()
{
while (true)
{
string filepath = Application.persistentDataPath + "/profilerData" + frameCount + ".log";
Profiler.logFile = filepath;
Profiler.enableBinaryLog = true;
Profiler.enabled = true;
for (int i = 0; i < 300; i++)
{
yield return new WaitForEndOfFrame();
if (!Profiler.enabled)
Profiler.enabled = true;
}
frameCount++;
}
}
}
Then, you can load the log files (each containing 300 frames of data) in the Profiler, or you can write a class in order to execute the loading from the Editor.
Upvotes: 3