Version: Unity 6.7 Beta (6000.7)
LanguageEnglish
  • C#

EnergyUsageSubsystem

enumeration

Suggest a change

Success!

Thank you for helping us improve the quality of Unity Documentation. Although we cannot accept all submissions, we do read each suggested change from our users and will make updates where applicable.

Close

Submission failed

For some reason your suggested change could not be submitted. Please <a>try again</a> in a few minutes. And thank you for taking the time to help us improve the quality of Unity Documentation.

Close

Cancel

Description

Identifies a device hardware subsystem that can report energy consumption through EnergyUsage.

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.

 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(); } }

Properties

Property Description
Cpu The CPU subsystem.
Gpu The GPU subsystem.
Tpu The Tensor (neural) processing unit subsystem.
Display The display subsystem.
Memory The memory (DRAM) subsystem.