GpuPerformanceMeter

class GpuPerformanceMeter(samples: Int, timestampPeriodNanos: Double, scope: String, readTimestamp: (Int) -> Long?) : AutoCloseable(source)

Collects completed native timestamp pairs without inferring GPU work from a CPU clock.

The host owns query allocation, placement, submission, completion and release on its render thread. readTimestamp is borrowed until close; null means the actual query has not completed. Tick conversion uses the loaded device's positive timestampPeriodNanos, never a backend-name assumption. Storage is bounded by samples; the host calls begin before its owner-thread operation and recorded after recording the pair. This collector measures only scope; unrelated host commands inside that boundary are included.

Constructors

Link copied to clipboard
constructor(samples: Int, timestampPeriodNanos: Double, scope: String, readTimestamp: (Int) -> Long?)

Properties

Link copied to clipboard

True only when every recorded start and end query has a completed native value. This owner-thread poll does not block or submit new GPU work.

Functions

Link copied to clipboard
fun begin()

Starts one host operation and polls preceding completed pairs without blocking. The kit owns this wall clock; first-observed completion includes queueing and host polling delay.

Link copied to clipboard
open override fun close()

Severs the borrowed query reader; the host independently releases its completed native queries.

Link copied to clipboard
fun recorded()

Acknowledges a successfully recorded pair; missing or duplicate pairs cannot certify a complete interval.

Link copied to clipboard
fun result(): JsonObject

Returns detached nanosecond distributions after complete query evidence, without a frame or FPS claim. Reversed, overflowing or nonrepresentable timestamp differences reject the whole interval.