From ee8aedeb0bf409483b5c97c0de9168867037b618 Mon Sep 17 00:00:00 2001 From: Cassunshine Date: Mon, 22 Jan 2024 17:22:14 +0000 Subject: [PATCH] -Support setting profiler entry meta after push --- Core/Util/Profiling/Profiler.cs | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/Core/Util/Profiling/Profiler.cs b/Core/Util/Profiling/Profiler.cs index 168a698..d67cf4b 100644 --- a/Core/Util/Profiling/Profiler.cs +++ b/Core/Util/Profiling/Profiler.cs @@ -40,6 +40,12 @@ public static void Pop(ProfilerKey key) { State.Value.Pop(key, time); } + public static void SetCurrentMeta(string? value) { + if (!State.IsValueCreated) + throw new InvalidOperationException("Profiler state not created"); + + State.Value.SetCurrentMeta(value); + } public static void GetStateNames(List target) { target.Clear(); @@ -72,6 +78,11 @@ public void Push(ProfilerKey key, DateTime time, string? meta) { entryStack.Push(entry); } + public void SetCurrentMeta(string? meta) { + var entry = entryStack.Peek(); + entry.Meta = meta; + } + public void Pop(ProfilerKey key, DateTime time) { var top = entryStack.Pop();