Beispiel #1
0
        public HighPrecisionTimerTests()
        {
            var sw    = Stopwatch.StartNew();
            var timer = new HighPrecisionTimer();

            timer.Block(ExpectedTicks);
            sw.Stop();
            _ticks = sw.ElapsedTicks;
        }
Beispiel #2
0
 /// <summary>
 /// Uses the configured instruction timings to sync real time to the CPU.
 /// </summary>
 /// <param name="timings">The timings.</param>
 public void SyncToTimings(InstructionTimings timings)
 {
     // Check if we need to call the sync event.
     _cyclesSinceLastEventSync += timings.MachineCycles;
     if (_cyclesSinceLastEventSync > CyclesPerSyncEvent)
     {
         TimingSync?.Invoke(new InstructionTimings(_cyclesSinceLastEventSync));
         _timer.Block((long)(_ticksPerCycle * _cyclesSinceLastEventSync));
         _cyclesSinceLastEventSync = _cyclesSinceLastEventSync - CyclesPerSyncEvent;
     }
 }