# Scripting with Adaptive Performance

> Control and monitor device performance at runtime using the Adaptive Performance scripting API.

Control and monitor device performance at runtime using the Adaptive Performance scripting API.

After you [set up Adaptive Performance](/engine/6000.6/manual/analysis/runtime-performance-scaling/adaptive-performance/get-started/initial-setup.md), you can use its scripting API to access and control device performance metrics directly from your code. The central point of access is the [`IAdaptivePerformance`](/engine/6000.6/script-reference/unityengine/adaptiveperformance/iadaptiveperformance.md) interface, which Unity automatically creates and manages on a GameObject at runtime.

For a code-free approach using visual graphs, refer to the [Adaptive Performance package documentation about visual scripting](https://docs.unity3d.com/Packages/com.unity.adaptiveperformance@latest?subfolder=/manual/visual-scripting.html).

## Accessing the instance

To access the instance, use [`AdaptivePerformance.Holder.Instance`](/engine/6000.6/script-reference/unityengine/adaptiveperformance/holder/instance.md).

To check if your device supports Adaptive Performance, use the [`IAdaptivePerformance.Active`](/engine/6000.6/script-reference/unityengine/adaptiveperformance/iadaptiveperformance/active.md) property.

## Debug logging

To get detailed information during runtime, enable **Logging** in the [provider settings](/engine/6000.6/manual/analysis/runtime-performance-scaling/adaptive-performance/get-started/providers/provider-settings-reference.md) or via [`IDevelopmentSettings.Logging`](/engine/6000.6/script-reference/unityengine/adaptiveperformance/idevelopmentsettings/logging.md) during runtime or using boot time flags from [`IAdaptivePerformanceSettings`](/engine/6000.6/script-reference/unityengine/adaptiveperformance/iadaptiveperformancesettings.md):

```lang-cs

using UnityEngine;
using UnityEngine.AdaptivePerformance;

static class AdaptivePerformanceConfig
{
    // This method runs automatically after assemblies are loaded, before any scene starts.
    [RuntimeInitializeOnLoadMethod(RuntimeInitializeLoadType.AfterAssembliesLoaded)]
    static void Setup()
    {
        // Retrieve the Adaptive Performance settings.
        IAdaptivePerformanceSettings settings = AdaptivePerformanceGeneralSettings.Instance.Manager.activeLoader.GetSettings();
        // Check if settings were successfully retrieved before modifying.
        if (settings != null)
        {
            // Enable Adaptive Performance logging.
            settings.logging = true;
        }
    }
}
```

## Additional resources

* [Set up Adaptive Performance](/engine/6000.6/manual/analysis/runtime-performance-scaling/adaptive-performance/get-started/initial-setup.md)
* [Track timing and thermal data](/engine/6000.6/manual/analysis/runtime-performance-scaling/adaptive-performance/performance-metrics/track-timing-thermal-data.md)
