LoopTimer

Measures time intervals and calculates smoothed frequency (Hz).

Constructor

LoopTimer(smootherWindow: Int = 5)

  • smootherWindow: Window size for smoothing Hz values (default: 5).

Properties

NameTypeDescription
msLongLast measured interval (ms)
hzDoubleSmoothed frequency (Hz)
startTimeLongTimestamp of start() call
endTimeLongTimestamp of end() call

Methods

  • start() – Start timing.
  • end() – End timing, updates ms and hz.

Usage Example

val timer = LoopTimer()
timer.start()
// Simulate work
Thread.sleep(100)
timer.end()
println("Time: ${timer.ms}ms, Freq: ${timer.hz}Hz")
kotlin

A library by Lazar from 19234 ByteForce.