diff --git a/Ryujinx.Profiler/InternalProfile.cs b/Ryujinx.Profiler/InternalProfile.cs index 0d091f5358..4864232303 100644 --- a/Ryujinx.Profiler/InternalProfile.cs +++ b/Ryujinx.Profiler/InternalProfile.cs @@ -50,14 +50,18 @@ namespace Ryujinx.Profiler BeginTime = timestamp, LastTime = 0, Count = 0, + Instant = 0, + InstantCount = 0, }; } private TimingInfo UpdateTimer(TimingInfo time, long timestamp) { time.Count++; + time.InstantCount++; time.LastTime = timestamp - time.BeginTime; time.TotalTime += time.LastTime; + time.Instant += time.LastTime; return time; } @@ -83,6 +87,18 @@ namespace Ryujinx.Profiler outDict.Add(configs[i], times[i]); } + foreach (ProfileConfig key in Timers.Keys) + { + TimingInfo value, prevValue; + if (Timers.TryGetValue(key, out value)) + { + prevValue = value; + value.Instant = 0; + value.InstantCount = 0; + Timers.TryUpdate(key, value, prevValue); + } + } + return outDict; } } diff --git a/Ryujinx.Profiler/TimingInfo.cs b/Ryujinx.Profiler/TimingInfo.cs index d9c3f7f2fb..f1443d4bfd 100644 --- a/Ryujinx.Profiler/TimingInfo.cs +++ b/Ryujinx.Profiler/TimingInfo.cs @@ -2,7 +2,8 @@ { public struct TimingInfo { - public long BeginTime, LastTime, TotalTime, Count; + public long BeginTime, LastTime, TotalTime, Instant; + public int Count, InstantCount; public long AverageTime { get => (Count == 0) ? -1 : TotalTime / Count; diff --git a/Ryujinx.Profiler/UI/ProfileSorters.cs b/Ryujinx.Profiler/UI/ProfileSorters.cs index 5ecc4d6466..697e8fec2e 100644 --- a/Ryujinx.Profiler/UI/ProfileSorters.cs +++ b/Ryujinx.Profiler/UI/ProfileSorters.cs @@ -9,7 +9,7 @@ namespace Ryujinx.Profiler.UI public class InstantAscending : IComparer> { public int Compare(KeyValuePair pair1, KeyValuePair pair2) - => pair2.Value.LastTime.CompareTo(pair1.Value.LastTime); + => pair2.Value.Instant.CompareTo(pair1.Value.Instant); } public class AverageAscending : IComparer> diff --git a/Ryujinx.Profiler/UI/ProfileWindow.cs b/Ryujinx.Profiler/UI/ProfileWindow.cs index d8c87ff5b8..0cab7b7d8b 100644 --- a/Ryujinx.Profiler/UI/ProfileWindow.cs +++ b/Ryujinx.Profiler/UI/ProfileWindow.cs @@ -137,10 +137,17 @@ namespace Ryujinx profileData.Sort(sortAction); } - Regex filterRegex = new Regex(FilterText); - if (FilterText != "") + try { - profileData = profileData.Where((pair => filterRegex.IsMatch(pair.Key.Tag))).ToList(); + Regex filterRegex = new Regex(FilterText); + if (FilterText != "") + { + profileData = profileData.Where((pair => filterRegex.IsMatch(pair.Key.Tag))).ToList(); + } + } + catch (ArgumentException argException) + { + // Skip filtering for invalid regex } } #endregion @@ -268,7 +275,7 @@ namespace Ryujinx if (profileData.Count != 0) { width = Width - xOffset - 370; - int maxInstant = profileData.Max((kvp) => (int) kvp.Value.LastTime); + int maxInstant = profileData.Max((kvp) => (int) kvp.Value.Instant); int maxAverage = profileData.Max((kvp) => (int) kvp.Value.AverageTime); int maxTotal = profileData.Max((kvp) => (int) kvp.Value.TotalTime); float barHeight = (lineHeight - linePadding) / 3.0f; @@ -282,7 +289,7 @@ namespace Ryujinx GL.Color3(Color.Blue); float bottom = GetLineY(yOffset, lineHeight, linePadding, true, verticalIndex++); float top = bottom + barHeight; - float right = (float) entry.Value.LastTime / maxInstant * width + xOffset; + float right = (float) entry.Value.Instant / maxInstant * width + xOffset; GL.Vertex2(xOffset, bottom); GL.Vertex2(xOffset, top); GL.Vertex2(right, top); @@ -331,19 +338,19 @@ namespace Ryujinx foreach (var entry in profileData) { float y = GetLineY(yOffset, lineHeight, linePadding, true, verticalIndex++); - fontService.DrawText($"{Profile.ConvertTicksToMS(entry.Value.LastTime):F3}", xOffset, y, lineHeight); - fontService.DrawText($"{Profile.ConvertTicksToMS(entry.Value.AverageTime):F3}", columnSpacing + 100 + xOffset, y, lineHeight); + fontService.DrawText($"{Profile.ConvertTicksToMS(entry.Value.Instant):F3} ({entry.Value.InstantCount})", xOffset, y, lineHeight); + fontService.DrawText($"{Profile.ConvertTicksToMS(entry.Value.AverageTime):F3}", columnSpacing + 120 + xOffset, y, lineHeight); fontService.DrawText($"{Profile.ConvertTicksToMS(entry.Value.TotalTime):F3}", columnSpacing + columnSpacing + 200 + xOffset, y, lineHeight); } GL.Disable(EnableCap.ScissorTest); float yHeight = Height - titleFontHeight; - fontService.DrawText("Instant (ms)", xOffset, yHeight, titleFontHeight); + fontService.DrawText("Instant (ms, count)", xOffset, yHeight, titleFontHeight); buttons[(int)ButtonIndex.InstantTitle].UpdateSize((int)xOffset, (int)yHeight, 0, (int)(columnSpacing + 100), titleFontHeight); - fontService.DrawText("Average (ms)", columnSpacing + 100 + xOffset, yHeight, titleFontHeight); - buttons[(int)ButtonIndex.AverageTitle].UpdateSize((int)(columnSpacing + 100 + xOffset), (int)yHeight, 0, (int)(columnSpacing + 100), titleFontHeight); + fontService.DrawText("Average (ms)", columnSpacing + 120 + xOffset, yHeight, titleFontHeight); + buttons[(int)ButtonIndex.AverageTitle].UpdateSize((int)(columnSpacing + 120 + xOffset), (int)yHeight, 0, (int)(columnSpacing + 100), titleFontHeight); fontService.DrawText("Total (ms)", columnSpacing + columnSpacing + 200 + xOffset, yHeight, titleFontHeight); buttons[(int)ButtonIndex.TotalTitle].UpdateSize((int)(columnSpacing + columnSpacing + 200 + xOffset), (int)yHeight, 0, Width, titleFontHeight);