Class FrequencyCalculator

java.lang.Object
net.emustudio.emulib.plugin.cpu.FrequencyCalculator
All Implemented Interfaces:
CPUContext.PassedCyclesListener

public final class FrequencyCalculator extends Object implements CPUContext.PassedCyclesListener
Measures average CPU frequency in kHz without owning a thread. The CPU worker calls start, passedCycles, and stop; observers call sample. Cycle publication is batched to keep atomic updates out of the instruction loop. Sampling returns a value without publishing execution notifications.
  • Constructor Details

    • FrequencyCalculator

      public FrequencyCalculator()
  • Method Details

    • start

      public void start()
      Starts a measurement on the CPU worker.
    • passedCycles

      public void passedCycles(long cyclesDelta)
      Called only by the CPU worker, including start/stop ordering.
      Specified by:
      passedCycles in interface CPUContext.PassedCyclesListener
      Parameters:
      cyclesDelta - cycles that were executed (delta from the last call)
    • stop

      public void stop()
      Publishes the final partial batch after actual execution exit.
    • sample

      public float sample()
      Reads the current measurement; never schedules work itself.