Documentation

Unity Engine


User Manual

Script Reference

Unity Engine


EnergyUsageSubsystem

Identifies a device hardware subsystem that can report energy consumption through EnergyUsage.
Read time 1 minuteLast updated 12 days ago

Definition

public enum EnergyUsageSubsystem

Remarks

Pass a value from this enum to EnergyUsage.Get to read how much energy a single subsystem consumed since energy-usage tracking was started or reset with IEnergyUsageControl.StartEnergyUsageTracking.
Each subsystem reports independently of the others, because devices expose different sets of power monitors. A platform reports only the subsystems its monitors cover and returns an unavailable reading for the rest, so check EnergyUsageReading.Available on each reading before you use its values instead of assuming that a subsystem missing on one device is missing on all devices.
The following example tracks energy usage while a component is enabled and logs how much energy the CPU subsystem consumed since tracking started.

Examples

using UnityEngine;using UnityEngine.AdaptivePerformance;public class CpuEnergyUsageExample : MonoBehaviour{ IAdaptivePerformance adaptivePerformance; IEnergyUsageControl energyUsageControl; void OnEnable() { adaptivePerformance = Holder.Instance; if (adaptivePerformance == null || !adaptivePerformance.Initialized) return; energyUsageControl = adaptivePerformance.EnergyUsageControl(); if (energyUsageControl == null || !energyUsageControl.StartEnergyUsageTracking()) Debug.Log("Energy-usage tracking isn't available on this device."); } void Update() { if (energyUsageControl == null || !energyUsageControl.EnergyUsageTrackingActive) return; EnergyUsage energyUsage = adaptivePerformance.PerformanceStatus.PerformanceMetrics.EnergyUsage; EnergyUsageReading reading = energyUsage.Get(EnergyUsageSubsystem.Cpu); // This device doesn't report energy for this subsystem, so skip it. if (!reading.Available) return; Debug.Log($"The CPU used {reading.Energy} microwatt-seconds over {reading.Interval} ms."); } void OnDisable() { energyUsageControl?.StopEnergyUsageTracking(); }}

Fields

Value

Description

CpuThe CPU subsystem.
DisplayThe display subsystem.
GpuThe GPU subsystem.
MemoryThe memory (DRAM) subsystem.
TpuThe Tensor (neural) processing unit subsystem.