Class IOReportClient
java.lang.Object
oshi.driver.mac.IOReportClient
Manages a single IOReport subscription for GPU Stats and Energy Model channels, providing per-instance sampling of
GPU active ticks, utilization, and power draw.
Each instance holds its own subscription and previous-sample state, making it suitable for use inside a
GpuStats session with explicit lifecycle management.
Call close() when done to release all CoreFoundation references. After close(), all sampling methods
return sentinel values.
-
Method Summary
Modifier and TypeMethodDescriptionvoidclose()Releases all CoreFoundation references held by this client.static IOReportClientcreate()Creates a newIOReportClientsubscribed to GPU Stats and Energy Model channels.Returns aGpuTickssnapshot of cumulative GPU active and idle ticks in raw IOReport residency units.doubleReturns instantaneous GPU utilization as a percentage (0–100), or-1.0if unavailable or closed.doubleReturns instantaneous GPU power in watts, or-1.0if unavailable or closed.
-
Method Details
-
create
Creates a newIOReportClientsubscribed to GPU Stats and Energy Model channels.- Returns:
- a new client, or
nullif IOReport is unavailable or subscription fails
-
sampleGpuTicks
Returns aGpuTickssnapshot of cumulative GPU active and idle ticks in raw IOReport residency units. The kernel residency counters are monotonically increasing; callers diff two snapshots to compute utilization:dActive / (dActive + dIdle).- Returns:
- GpuTicks snapshot; never null
-
sampleGpuUtilization
public double sampleGpuUtilization()Returns instantaneous GPU utilization as a percentage (0–100), or-1.0if unavailable or closed.- Returns:
- GPU utilization percentage, or -1.0
-
samplePowerWatts
public double samplePowerWatts()Returns instantaneous GPU power in watts, or-1.0if unavailable or closed.- Returns:
- GPU power in watts, or -1.0
-
close
public void close()Releases all CoreFoundation references held by this client. Idempotent.
-