Skip to content

Commit 3eab2a5

Browse files
committed
Add profiler markers for measuring enabling/disabling of InputActions and for binding resolution.
1 parent 343e8bf commit 3eab2a5

File tree

2 files changed

+14
-0
lines changed

2 files changed

+14
-0
lines changed

Packages/com.unity.inputsystem/InputSystem/Actions/InputAction.cs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
using System;
22
using Unity.Collections.LowLevel.Unsafe;
3+
using Unity.Profiling;
34
using UnityEngine.InputSystem.Controls;
45
using UnityEngine.InputSystem.LowLevel;
56
using UnityEngine.InputSystem.Utilities;
@@ -681,6 +682,11 @@ public bool wantsInitialStateCheck
681682
}
682683
}
683684

685+
/// <summary>
686+
/// ProfilerMarker for measuring the enabling/disabling of InputActions.
687+
/// </summary>
688+
static readonly ProfilerMarker k_InputActionEnableProfilerMarker = new ProfilerMarker("InputAction.Enable");
689+
684690
/// <summary>
685691
/// Construct an unnamed, free-standing action that is not part of any map or asset
686692
/// and has no bindings. Bindings can be added with <see
@@ -902,6 +908,7 @@ public void Enable()
902908
if (enabled)
903909
return;
904910

911+
k_InputActionEnableProfilerMarker.Auto();
905912
// For singleton actions, we create an internal-only InputActionMap
906913
// private to the action.
907914
var map = GetOrCreateActionMap();

Packages/com.unity.inputsystem/InputSystem/Actions/InputActionMap.cs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
using System.Collections.Generic;
44
using System.Linq;
55
using Unity.Collections;
6+
using Unity.Profiling;
67
using UnityEngine.InputSystem.Utilities;
78

89
////REVIEW: given we have the global ActionPerformed callback, do we really need the per-map callback?
@@ -313,6 +314,11 @@ public event Action<InputAction.CallbackContext> actionTriggered
313314
remove => m_ActionCallbacks.RemoveCallback(value);
314315
}
315316

317+
/// <summary>
318+
/// ProfilerMarker to measure how long it takes to resolve bindings.
319+
/// </summary>
320+
static readonly ProfilerMarker k_ResolveBindingsProfilerMarker = new("InputActionMap.ResolveBindings");
321+
316322
/// <summary>
317323
/// Construct an action map with default values.
318324
/// </summary>
@@ -1299,6 +1305,7 @@ internal bool ResolveBindingsIfNecessary()
12991305
/// </remarks>
13001306
internal void ResolveBindings()
13011307
{
1308+
k_ResolveBindingsProfilerMarker.Auto();
13021309
// Make sure that if we trigger callbacks as part of disabling and re-enabling actions,
13031310
// we don't trigger a re-resolve while we're already resolving bindings.
13041311
using (InputActionRebindingExtensions.DeferBindingResolution())

0 commit comments

Comments
 (0)