Skip to content

Commit

Permalink
Other: Sample the machine at 1 second intervals.
Browse files Browse the repository at this point in the history
Was previously 2 per second, which was a bit excessive.  This way we get 4 minutes of history recorded.
  • Loading branch information
deanthecoder committed Feb 10, 2024
1 parent 94b9be9 commit 9aad380
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions Speculator/Speculator.Core/CpuHistory.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ namespace Speculator.Core;
/// </summary>
public class CpuHistory : ViewModelBase
{
private const int SamplesPerSecond = 2;
private readonly ZxFileIo m_zxFileIo;
private const int MaxSamples = 240;
private readonly long m_ticksPerSample;
Expand Down Expand Up @@ -65,7 +64,7 @@ public CpuHistory(CPU theCpu, ZxFileIo zxFileIo)
m_zxFileIo = zxFileIo;
TheCpu = theCpu;
theCpu.Ticked += OnCpuTicked;
m_ticksPerSample = (long)(CPU.TStatesPerSecond / SamplesPerSecond); // Two samples per second.
m_ticksPerSample = (long)CPU.TStatesPerSecond;
m_ticksToNextSample = m_ticksPerSample * 5; // Start 5 seconds after machine start.
m_lastTStateCount = 0;
}
Expand Down Expand Up @@ -110,9 +109,8 @@ public void RollbackByTime(int goBackSecs)
{
if (m_snapshots.Count == 0)
return;

var snapshotCount = goBackSecs * SamplesPerSecond;
IndexToRestore = Math.Max(0, m_snapshots.Count - snapshotCount);

IndexToRestore = Math.Max(0, m_snapshots.Count - goBackSecs);
Rollback();
}
}

0 comments on commit 9aad380

Please sign in to comment.