Better instant timing calculation
Fixed minor regex bug
This commit is contained in:
parent
644221319c
commit
97fdad7b0c
4 changed files with 36 additions and 12 deletions
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -9,7 +9,7 @@ namespace Ryujinx.Profiler.UI
|
|||
public class InstantAscending : IComparer<KeyValuePair<ProfileConfig, TimingInfo>>
|
||||
{
|
||||
public int Compare(KeyValuePair<ProfileConfig, TimingInfo> pair1, KeyValuePair<ProfileConfig, TimingInfo> pair2)
|
||||
=> pair2.Value.LastTime.CompareTo(pair1.Value.LastTime);
|
||||
=> pair2.Value.Instant.CompareTo(pair1.Value.Instant);
|
||||
}
|
||||
|
||||
public class AverageAscending : IComparer<KeyValuePair<ProfileConfig, TimingInfo>>
|
||||
|
|
|
@ -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);
|
||||
|
|
Loading…
Add table
Reference in a new issue