Fixed flag times
Dispays time flags in window
This commit is contained in:
parent
ca8a064135
commit
7d33087339
3 changed files with 62 additions and 30 deletions
|
@ -34,6 +34,7 @@ namespace Ryujinx.Profiler
|
||||||
private TimingFlag[] _timingFlags;
|
private TimingFlag[] _timingFlags;
|
||||||
private long[] _timingFlagAverages;
|
private long[] _timingFlagAverages;
|
||||||
private long[] _timingFlagLast;
|
private long[] _timingFlagLast;
|
||||||
|
private long[] _timingFlagLastDelta;
|
||||||
private int _timingFlagCount;
|
private int _timingFlagCount;
|
||||||
private int _timingFlagIndex;
|
private int _timingFlagIndex;
|
||||||
|
|
||||||
|
@ -48,6 +49,7 @@ namespace Ryujinx.Profiler
|
||||||
_timingFlags = new TimingFlag[_maxFlags];
|
_timingFlags = new TimingFlag[_maxFlags];
|
||||||
_timingFlagAverages = new long[(int)TimingFlagType.Count];
|
_timingFlagAverages = new long[(int)TimingFlagType.Count];
|
||||||
_timingFlagLast = new long[(int)TimingFlagType.Count];
|
_timingFlagLast = new long[(int)TimingFlagType.Count];
|
||||||
|
_timingFlagLastDelta = new long[(int)TimingFlagType.Count];
|
||||||
_timerQueue = new ConcurrentQueue<TimerQueueValue>();
|
_timerQueue = new ConcurrentQueue<TimerQueueValue>();
|
||||||
_history = history;
|
_history = history;
|
||||||
_cleanupRunning = true;
|
_cleanupRunning = true;
|
||||||
|
@ -127,28 +129,24 @@ namespace Ryujinx.Profiler
|
||||||
Timestamp = PerformanceCounter.ElapsedTicks
|
Timestamp = PerformanceCounter.ElapsedTicks
|
||||||
};
|
};
|
||||||
|
|
||||||
if (++_timingFlagIndex >= _maxFlags)
|
|
||||||
{
|
|
||||||
_timingFlagIndex = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
_timingFlagCount = Math.Max(_timingFlagCount + 1, _maxFlags);
|
_timingFlagCount = Math.Max(_timingFlagCount + 1, _maxFlags);
|
||||||
|
|
||||||
// Work out average
|
// Work out average
|
||||||
if (_timingFlagLast[flagId] == 0)
|
if (_timingFlagLast[flagId] != 0)
|
||||||
{
|
{
|
||||||
_timingFlagAverages[flagId] = _timingFlags[_timingFlagIndex].Timestamp;
|
_timingFlagLastDelta[flagId] = _timingFlags[_timingFlagIndex].Timestamp - _timingFlagLast[flagId];
|
||||||
}
|
_timingFlagAverages[flagId] = (_timingFlagAverages[flagId] == 0) ? _timingFlagLastDelta[flagId] :
|
||||||
else
|
(_timingFlagLastDelta[flagId] + _timingFlagAverages[flagId]) >> 1;
|
||||||
{
|
|
||||||
_timingFlagAverages[flagId] = (_timingFlags[_timingFlagIndex].Timestamp + _timingFlagLast[flagId]) / 2;
|
|
||||||
}
|
}
|
||||||
|
_timingFlagLast[flagId] = _timingFlags[_timingFlagIndex].Timestamp;
|
||||||
|
|
||||||
// Notify subscribers
|
// Notify subscribers
|
||||||
_timingFlagCallback?.Invoke(_timingFlags[_timingFlagIndex]);
|
_timingFlagCallback?.Invoke(_timingFlags[_timingFlagIndex]);
|
||||||
|
|
||||||
// Set last time for average
|
if (++_timingFlagIndex >= _maxFlags)
|
||||||
_timingFlagLast[flagId] = _timingFlags[_timingFlagIndex].Timestamp;
|
{
|
||||||
|
_timingFlagIndex = 0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void BeginProfile(ProfileConfig config)
|
public void BeginProfile(ProfileConfig config)
|
||||||
|
@ -209,6 +207,11 @@ namespace Ryujinx.Profiler
|
||||||
return outFlags;
|
return outFlags;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public (long[], long[]) GetTimingAveragesAndLast()
|
||||||
|
{
|
||||||
|
return (_timingFlagAverages, _timingFlagLastDelta);
|
||||||
|
}
|
||||||
|
|
||||||
public void RegisterFlagReciever(Action<TimingFlag> reciever)
|
public void RegisterFlagReciever(Action<TimingFlag> reciever)
|
||||||
{
|
{
|
||||||
_timingFlagCallback = reciever;
|
_timingFlagCallback = reciever;
|
||||||
|
|
|
@ -128,5 +128,16 @@ namespace Ryujinx.Profiler
|
||||||
return new TimingFlag[0];
|
return new TimingFlag[0];
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static (long[], long[]) GetTimingAveragesAndLast()
|
||||||
|
{
|
||||||
|
#if USE_PROFILING
|
||||||
|
if (!ProfilingEnabled())
|
||||||
|
return (new long[0], new long[0]);
|
||||||
|
return _profileInstance.GetTimingAveragesAndLast();
|
||||||
|
#else
|
||||||
|
return (new long[0], new long[0]);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -63,6 +63,10 @@ namespace Ryujinx.Profiler.UI
|
||||||
private List<KeyValuePair<ProfileConfig, TimingInfo>> _unsortedProfileData;
|
private List<KeyValuePair<ProfileConfig, TimingInfo>> _unsortedProfileData;
|
||||||
private IComparer<KeyValuePair<ProfileConfig, TimingInfo>> _sortAction = new ProfileSorters.TagAscending();
|
private IComparer<KeyValuePair<ProfileConfig, TimingInfo>> _sortAction = new ProfileSorters.TagAscending();
|
||||||
|
|
||||||
|
// Flag data
|
||||||
|
private long[] _timingFlagsAverages;
|
||||||
|
private long[] _timingFlagsLast;
|
||||||
|
|
||||||
// Filtering
|
// Filtering
|
||||||
private string _filterText = "";
|
private string _filterText = "";
|
||||||
private bool _regexEnabled = false;
|
private bool _regexEnabled = false;
|
||||||
|
@ -246,6 +250,7 @@ namespace Ryujinx.Profiler.UI
|
||||||
Dictionary<ProfileConfig, TimingInfo> data = Profile.GetProfilingData();
|
Dictionary<ProfileConfig, TimingInfo> data = Profile.GetProfilingData();
|
||||||
if (data.Count > 0)
|
if (data.Count > 0)
|
||||||
{
|
{
|
||||||
|
(_timingFlagsAverages, _timingFlagsLast) = Profile.GetTimingAveragesAndLast();
|
||||||
_unsortedProfileData = data.ToList();
|
_unsortedProfileData = data.ToList();
|
||||||
_profileUpdated = true;
|
_profileUpdated = true;
|
||||||
}
|
}
|
||||||
|
@ -527,13 +532,11 @@ namespace Ryujinx.Profiler.UI
|
||||||
{
|
{
|
||||||
float y = GetLineY(yOffset, LineHeight, LinePadding, true, verticalIndex++);
|
float y = GetLineY(yOffset, LineHeight, LinePadding, true, verticalIndex++);
|
||||||
|
|
||||||
float instant = (float)entry.Value.Instant / PerformanceCounter.TicksPerMillisecond;
|
_fontService.DrawText($"{GetTimeString(entry.Value.Instant)} ({entry.Value.InstantCount})", xOffset, y, LineHeight);
|
||||||
_fontService.DrawText($"{((instant < 1) ? $"{instant * 1000:F3}us" : $"{instant:F3}ms")} ({entry.Value.InstantCount})", xOffset, y, LineHeight);
|
|
||||||
|
|
||||||
float average = (float)entry.Value.AverageTime / PerformanceCounter.TicksPerMillisecond;
|
_fontService.DrawText(GetTimeString(entry.Value.AverageTime), 150 + xOffset, y, LineHeight);
|
||||||
_fontService.DrawText((average < 1) ? $"{average * 1000:F3}us" : $"{average:F3}ms", 150 + xOffset, y, LineHeight);
|
|
||||||
|
|
||||||
_fontService.DrawText($"{(float)entry.Value.TotalTime / PerformanceCounter.TicksPerMillisecond:F3}", 260 + xOffset, y, LineHeight);
|
_fontService.DrawText(GetTimeString(entry.Value.TotalTime), 260 + xOffset, y, LineHeight);
|
||||||
|
|
||||||
totalInstant += entry.Value.Instant;
|
totalInstant += entry.Value.Instant;
|
||||||
totalAverage += entry.Value.AverageTime;
|
totalAverage += entry.Value.AverageTime;
|
||||||
|
@ -554,10 +557,19 @@ namespace Ryujinx.Profiler.UI
|
||||||
_buttons[(int)ButtonIndex.TotalTitle].UpdateSize((int)(260 + xOffset), (int)yHeight, 0, Width, TitleFontHeight);
|
_buttons[(int)ButtonIndex.TotalTitle].UpdateSize((int)(260 + xOffset), (int)yHeight, 0, Width, TitleFontHeight);
|
||||||
|
|
||||||
// Totals
|
// Totals
|
||||||
yHeight = FilterHeight + 2;
|
yHeight = FilterHeight + 3;
|
||||||
_fontService.DrawText($"{totalInstant / PerformanceCounter.TicksPerMillisecond:F3} ({totalCount})", xOffset, yHeight, TitleFontHeight);
|
int textHeight = LineHeight - 2;
|
||||||
_fontService.DrawText($"{totalAverage / PerformanceCounter.TicksPerMillisecond:F3}", 150 + xOffset, yHeight, TitleFontHeight);
|
|
||||||
_fontService.DrawText($"{totalTime / PerformanceCounter.TicksPerMillisecond:F3}", 260 + xOffset, yHeight, TitleFontHeight);
|
float tempWidth = _fontService.DrawText($"Host {GetTimeString(_timingFlagsLast[(int)TimingFlagType.SystemFrame])} " +
|
||||||
|
$"({GetTimeString(_timingFlagsAverages[(int)TimingFlagType.SystemFrame])})", 5, yHeight, textHeight);
|
||||||
|
|
||||||
|
_fontService.DrawText($"Game {GetTimeString(_timingFlagsLast[(int)TimingFlagType.FrameSwap])} " +
|
||||||
|
$"({GetTimeString(_timingFlagsAverages[(int)TimingFlagType.FrameSwap])})", 15 + tempWidth, yHeight, textHeight);
|
||||||
|
|
||||||
|
|
||||||
|
_fontService.DrawText($"{GetTimeString(totalInstant)} ({totalCount})", xOffset, yHeight, textHeight);
|
||||||
|
_fontService.DrawText(GetTimeString(totalAverage), 150 + xOffset, yHeight, textHeight);
|
||||||
|
_fontService.DrawText(GetTimeString(totalTime), 260 + xOffset, yHeight, textHeight);
|
||||||
#endregion
|
#endregion
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -639,6 +651,12 @@ namespace Ryujinx.Profiler.UI
|
||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
private string GetTimeString(long timestamp)
|
||||||
|
{
|
||||||
|
float time = (float)timestamp / PerformanceCounter.TicksPerMillisecond;
|
||||||
|
return (time < 1) ? $"{time * 1000:F3}us" : $"{time:F3}ms";
|
||||||
|
}
|
||||||
|
|
||||||
private void FilterBackspace()
|
private void FilterBackspace()
|
||||||
{
|
{
|
||||||
if (_filterText.Length <= 1)
|
if (_filterText.Length <= 1)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue