Class GpuTicks

java.lang.Object
oshi.hardware.GpuTicks

@Immutable public final class GpuTicks extends Object
An immutable snapshot of cumulative GPU active and idle tick counters in opaque, platform-native units.

Because activeTicks + idleTicks = total elapsed ticks, callers can compute utilization from two snapshots without needing a separate timestamp:

long dActive = curr.getActiveTicks() - prev.getActiveTicks();
long dIdle = curr.getIdleTicks() - prev.getIdleTicks();
long dTotal = dActive + dIdle;
double util = dTotal > 0 ? dActive * 100.0 / dTotal : -1d;

Both counters are 0 when tick-level metrics are not available on this platform. Because 0 is also the natural starting value of a real counter, callers cannot distinguish "not available" from "counter just started" — but the dTotal > 0 guard in the utilization formula handles both cases correctly.

  • Constructor Details

    • GpuTicks

      public GpuTicks(long activeTicks, long idleTicks)
      Creates a new snapshot.
      Parameters:
      activeTicks - cumulative GPU active ticks in platform-native units
      idleTicks - cumulative GPU idle ticks in platform-native units
  • Method Details

    • getActiveTicks

      public long getActiveTicks()
      Returns:
      cumulative GPU active ticks in platform-native units
    • getIdleTicks

      public long getIdleTicks()
      Returns:
      cumulative GPU idle ticks in platform-native units
    • toString

      public String toString()
      Overrides:
      toString in class Object