LoopTimer
Measures time intervals and calculates smoothed frequency (Hz).
Constructor
LoopTimer(smootherWindow: Int = 5)
smootherWindow
: Window size for smoothing Hz values (default: 5).
Properties
Name | Type | Description |
---|---|---|
ms | Long | Last measured interval (ms) |
hz | Double | Smoothed frequency (Hz) |
startTime | Long | Timestamp of start() call |
endTime | Long | Timestamp of end() call |
Methods
start()
– Start timing.end()
– End timing, updatesms
andhz
.
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.
On this page