-
-
Save ArieLeo/fe7f183869f6f78b81e1a5b516419b56 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System.Collections; | |
using System.Collections.Generic; | |
using UnityEngine; | |
using Unity.Profiling; | |
using UnityEngine.UI; | |
using System.Text; | |
using Unity.Profiling.LowLevel.Unsafe; | |
public class ReleaseBuildRecordCheck : MonoBehaviour | |
{ | |
public Text info; | |
List<ProfilerRecorderHandle> handles = new List<ProfilerRecorderHandle>(); | |
private List<string> recordNames; | |
private List<ProfilerRecorder> recorders; | |
private StringBuilder stringBuilder = new StringBuilder(); | |
// Start is called before the first frame update | |
void Start() | |
{ | |
this.recordNames = new List<string>(); | |
this.recorders = new List<ProfilerRecorder>(); | |
ProfilerRecorderHandle.GetAvailable(this.handles); | |
foreach (var handle in handles) | |
{ | |
if (handle.Valid) | |
{ | |
var statDesc = ProfilerRecorderHandle.GetDescription(handle); | |
recordNames.Add(statDesc.Name); | |
var recorder = new Unity.Profiling.ProfilerRecorder(statDesc.Name); | |
recorder.Start(); | |
recorders.Add(recorder); | |
} | |
} | |
} | |
// Update is called once per frame | |
void Update() | |
{ | |
if(Time.frameCount%30 != 0) { return; } | |
stringBuilder.Clear(); | |
stringBuilder.Append("count ").Append(recordNames.Count).Append("\n"); | |
for (int i = 0; i < recordNames.Count; i++) | |
{ | |
stringBuilder.Append(recordNames[i]).Append("::"). | |
Append(recorders[i].LastValueAsDouble).Append(" "); | |
if(i % 3 == 0 || true) | |
{ | |
stringBuilder.Append("\n"); | |
} | |
} | |
if (info) | |
{ | |
info.text = stringBuilder.ToString(); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment