diff --git a/Packages/deltaneverused.udonsharpprofiler/Editor/EmitAllProgramsPatch.cs b/Packages/deltaneverused.udonsharpprofiler/Editor/EmitAllProgramsPatch.cs index e42650a..5aed023 100644 --- a/Packages/deltaneverused.udonsharpprofiler/Editor/EmitAllProgramsPatch.cs +++ b/Packages/deltaneverused.udonsharpprofiler/Editor/EmitAllProgramsPatch.cs @@ -63,14 +63,14 @@ public static IEnumerable Transpiler(IEnumerable /// Packets from the object's profiling dict - [RecursiveMethod, DontUdonProfile] - private void EmitTree(DataDictionary node) { + [DontUdonProfile] + private void EmitPacket(DataDictionary node) { var start = (long)((double)node["start"].Long / Stopwatch.Frequency * 1000000d); // in microseconds var end = (long)((double)node["end"].Long / Stopwatch.Frequency * 1000000d); // in microseconds var functionName = node["name"].String; @@ -65,13 +65,6 @@ private void EmitTree(DataDictionary node) { .AddDuration(end - start) .AddEventType(PerfettoTrackEventType.TYPE_SLICE_COMPLETE) .AddIds()); - - // Get the children - var children = node["children"].DataList.ToArray(); - foreach (var child in children) { - // Repeat on that child - EmitTree(child.DataDictionary); - } } [DontUdonProfile] @@ -88,16 +81,16 @@ public override void PostLateUpdate() { if (recording) { // Get every called function from the "root" or for example: Update, Start, or input events - var root = (DataDictionary)target.GetProgramVariable(UdonProfilerConsts.StopwatchHeapKey); - var keys = root.GetKeys().ToArray(); + var root = (DataList)target.GetProgramVariable(UdonProfilerConsts.StopwatchListKey); + var unformattedPackets = root.ToArray(); - foreach (var key in keys) { - EmitTree(root[key].DataDictionary); + foreach (var unformattedPacket in unformattedPackets) { + EmitPacket(unformattedPacket.DataDictionary); } } // Reset Dict after getting it - target.SetProgramVariable(UdonProfilerConsts.StopwatchHeapKey, new DataDictionary()); + target.SetProgramVariable(UdonProfilerConsts.StopwatchListKey, new DataList()); } Emit(PerfettoHelper.CreatePacket() diff --git a/Packages/deltaneverused.udonsharpprofiler/Runtime/UdonProfilerConsts.cs b/Packages/deltaneverused.udonsharpprofiler/Runtime/UdonProfilerConsts.cs index 5361dfd..bc882fe 100644 --- a/Packages/deltaneverused.udonsharpprofiler/Runtime/UdonProfilerConsts.cs +++ b/Packages/deltaneverused.udonsharpprofiler/Runtime/UdonProfilerConsts.cs @@ -1,7 +1,7 @@ namespace UdonSharpProfiler { public static class UdonProfilerConsts { - public const string StopwatchHeapKey = "__refl_stopwatch_dict"; - public const string StopwatchHeapParentKey = "__refl_stopwatch_parent_dict"; + public const string StopwatchListKey = "__refl_stopwatch_list"; + public const string StopwatchParentKey = "__refl_stopwatch_parent_dict"; public const string StopwatchSelfKey = "__refl_stopwatch_self"; public const string StopwatchNameKey = "__refl_stopwatch_name";