Stop data running away when paused and frame updated
This commit is contained in:
parent
9f3b0cd1ef
commit
2ab9428aad
4 changed files with 27 additions and 7 deletions
|
@ -21,6 +21,7 @@ namespace Ryujinx.Profiler
|
|||
private readonly Thread _cleanupThread;
|
||||
private bool _cleanupRunning;
|
||||
private readonly long _history;
|
||||
private long _preserve;
|
||||
|
||||
// Timing flags
|
||||
private TimingFlag[] _timingFlags;
|
||||
|
@ -53,7 +54,7 @@ namespace Ryujinx.Profiler
|
|||
{
|
||||
foreach (var timer in Timers)
|
||||
{
|
||||
timer.Value.Cleanup(SW.ElapsedTicks - _history);
|
||||
timer.Value.Cleanup(SW.ElapsedTicks - _history, _preserve - _history, _preserve);
|
||||
}
|
||||
|
||||
// No need to run too often
|
||||
|
@ -106,6 +107,8 @@ namespace Ryujinx.Profiler
|
|||
{
|
||||
Dictionary<ProfileConfig, TimingInfo> outDict = new Dictionary<ProfileConfig, TimingInfo>();
|
||||
|
||||
_preserve = SW.ElapsedTicks;
|
||||
|
||||
// Forcibly get copy so user doesn't block profiling
|
||||
ProfileConfig[] configs = Timers.Keys.ToArray();
|
||||
TimingInfo[] times = Timers.Values.ToArray();
|
||||
|
|
|
@ -117,15 +117,25 @@ namespace Ryujinx.Profiler
|
|||
}
|
||||
|
||||
// Remove any timestamps before given timestamp to free memory
|
||||
public void Cleanup(long before)
|
||||
public void Cleanup(long before, long preserveStart, long preserveEnd)
|
||||
{
|
||||
lock (_timestampListLock)
|
||||
{
|
||||
int toRemove = 0;
|
||||
int toRemove = 0;
|
||||
int toPreserveStart = 0;
|
||||
int toPreserveLen = 0;
|
||||
|
||||
for (int i = 0; i < _timestamps.Count; i++)
|
||||
{
|
||||
if (_timestamps[i].EndTime < before)
|
||||
if (_timestamps[i].EndTime < preserveStart)
|
||||
{
|
||||
toPreserveStart++;
|
||||
}
|
||||
else if (_timestamps[i].EndTime < preserveEnd)
|
||||
{
|
||||
toPreserveLen++;
|
||||
}
|
||||
else if (_timestamps[i].EndTime < before)
|
||||
{
|
||||
toRemove++;
|
||||
}
|
||||
|
@ -136,9 +146,14 @@ namespace Ryujinx.Profiler
|
|||
}
|
||||
}
|
||||
|
||||
if (toPreserveStart > 0)
|
||||
{
|
||||
_timestamps.RemoveRange(0, toPreserveStart);
|
||||
}
|
||||
|
||||
if (toRemove > 0)
|
||||
{
|
||||
_timestamps.RemoveRange(0, toRemove);
|
||||
_timestamps.RemoveRange(toPreserveStart + toPreserveLen, toRemove);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -217,6 +217,7 @@ namespace Ryujinx.Profiler.UI
|
|||
_updateTimer = 0;
|
||||
_unsortedProfileData = Profile.GetProfilingData().ToList();
|
||||
_captureTime = Profile.GetCurrentTime();
|
||||
_timingFlags = Profile.GetTimingFlags();
|
||||
_profileUpdated = true;
|
||||
}
|
||||
|
||||
|
|
|
@ -6,6 +6,8 @@ namespace Ryujinx.Profiler.UI
|
|||
{
|
||||
public partial class ProfileWindow
|
||||
{
|
||||
private TimingFlag[] _timingFlags;
|
||||
|
||||
private const float GraphMoveSpeed = 40000;
|
||||
private const float GraphZoomSpeed = 50;
|
||||
|
||||
|
@ -33,11 +35,10 @@ namespace Ryujinx.Profiler.UI
|
|||
}
|
||||
|
||||
// Draw timing flags
|
||||
TimingFlag[] timingFlags = Profile.GetTimingFlags();
|
||||
GL.Enable(EnableCap.ScissorTest);
|
||||
GL.Color3(Color.Gray);
|
||||
GL.Begin(PrimitiveType.Lines);
|
||||
foreach (TimingFlag timingFlag in timingFlags)
|
||||
foreach (TimingFlag timingFlag in _timingFlags)
|
||||
{
|
||||
int x = (int)(xOffset + width - ((float)(_captureTime - (timingFlag.Timestamp + graphPositionTicks)) / timeWidthTicks) * width);
|
||||
GL.Vertex2(x, 0);
|
||||
|
|
Loading…
Add table
Reference in a new issue