ThroughputMeter

class ThroughputMeter(timeSource: TimeSource = TimeSource.Monotonic)

Measures data throughput for BLE transfer operations.

Accumulates byte counts and computes throughput over the measurement window. Not thread-safe - confine to a single coroutine or use external serialization.

val meter = ThroughputMeter()
meter.start()
repeat(100) {
val data = peripheral.read(characteristic)
meter.record(data.size)
}
val result = meter.stop("GATT reads")
println("${result.bytesPerSecond / 1024} KB/s")

Constructors

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

Functions

Link copied to clipboard
fun record(bytes: Int)
Link copied to clipboard
fun start()
Link copied to clipboard