LatencyTracker

class LatencyTracker(timeSource: TimeSource = TimeSource.Monotonic)

Collects latency samples and computes percentile statistics. Not thread-safe - confine to a single coroutine or use external serialization.

val tracker = LatencyTracker()
repeat(50) {
tracker.measure { peripheral.read(characteristic) }
}
val stats = tracker.summarize("GATT read")
println("p50=${stats.p50}, p95=${stats.p95}, p99=${stats.p99}")

Constructors

Link copied to clipboard
constructor(timeSource: TimeSource = TimeSource.Monotonic)

Functions

Link copied to clipboard
suspend fun <T> measure(block: suspend () -> T): T
Link copied to clipboard
fun record(duration: Duration)
Link copied to clipboard
fun reset()
Link copied to clipboard