Class FrequencyCalculator
java.lang.Object
net.emustudio.emulib.plugin.cpu.FrequencyCalculator
- All Implemented Interfaces:
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 Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidpassedCycles(long cyclesDelta) Called only by the CPU worker, including start/stop ordering.floatsample()Reads the current measurement; never schedules work itself.voidstart()Starts a measurement on the CPU worker.voidstop()Publishes the final partial batch after actual execution exit.Methods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface CPUContext.PassedCyclesListener
passedCycles
-
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:
passedCyclesin interfaceCPUContext.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.
-