-
Notifications
You must be signed in to change notification settings - Fork 328
NEW: Add two performance tests measuring frame times #2027
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 5 commits
0e7ea94
09f414d
13f67b7
6ad080c
a64e990
79525e0
93dff2b
9d8d5f7
80f7c70
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,4 +1,5 @@ | ||
| using System; | ||
| using System.Collections; | ||
| using System.Collections.Generic; | ||
| using UnityEngine.InputSystem; | ||
| using UnityEngine.InputSystem.LowLevel; | ||
|
|
@@ -12,6 +13,7 @@ | |
| using UnityEngine.InputSystem.Users; | ||
| using UnityEngine.InputSystem.Utilities; | ||
| using UnityEngine.TestTools; | ||
| using static System.Collections.Specialized.BitVector32; | ||
|
|
||
| ////TODO: add test for domain reload logic | ||
|
|
||
|
|
@@ -1100,4 +1102,106 @@ public void Performance_OptimizedControls_ReadingPose4kTimes(OptimizationTestTyp | |
| } | ||
|
|
||
| #endif | ||
|
|
||
| #if UNITY_2022_3_OR_NEWER | ||
| [PrebuildSetup(typeof(ProjectWideActionsBuildSetup))] | ||
| [PostBuildCleanup(typeof(ProjectWideActionsBuildSetup))] | ||
| [UnityTest, Performance] | ||
| [Category("Performance")] | ||
| public IEnumerator Performance_MeasureInputSystemFrameTimeWithProfilerMarkers_FPS() | ||
| { | ||
| string[] markers = | ||
| { | ||
| "InputUpdate", | ||
| "InputSystem.onBeforeUpdate", | ||
| "InputSystem.onAfterUpdate", | ||
| "PreUpdate.NewInputUpdate", | ||
| "PreUpdate.InputForUIUpdate", | ||
| "FixedUpdate.NewInputFixedUpdate" | ||
| }; | ||
|
|
||
| var keyboard = InputSystem.AddDevice<Keyboard>(); | ||
| var mouse = InputSystem.AddDevice<Mouse>(); | ||
|
|
||
| var moveAction = InputSystem.actions.FindAction("Move"); | ||
| var lookAction = InputSystem.actions.FindAction("Look"); | ||
| var attackAction = InputSystem.actions.FindAction("Attack"); | ||
| var jumpAction = InputSystem.actions.FindAction("Jump"); | ||
| var sprintAction = InputSystem.actions.FindAction("Sprint"); | ||
|
|
||
| int performedCallCount = 0; | ||
|
|
||
| moveAction.performed += context => { | ||
| performedCallCount++; | ||
| }; | ||
|
|
||
| lookAction.performed += context => { | ||
| performedCallCount++; | ||
| }; | ||
|
|
||
| attackAction.performed += context => { | ||
| performedCallCount++; | ||
| }; | ||
|
|
||
| jumpAction.performed += context => { | ||
| performedCallCount++; | ||
| }; | ||
|
|
||
| sprintAction.performed += context => { | ||
| performedCallCount++; | ||
| }; | ||
|
|
||
| using (Measure.ProfilerMarkers(markers)) | ||
| { | ||
| for (int i = 0; i < 500; ++i) | ||
| { | ||
| PressAndRelease(keyboard.wKey, queueEventOnly: true); | ||
|
||
| PressAndRelease(keyboard.aKey, queueEventOnly: true); | ||
| PressAndRelease(keyboard.sKey, queueEventOnly: true); | ||
| PressAndRelease(keyboard.dKey, queueEventOnly: true); | ||
|
|
||
| PressAndRelease(keyboard.leftShiftKey, queueEventOnly: true); | ||
|
|
||
| PressAndRelease(keyboard.spaceKey, queueEventOnly: true); | ||
|
|
||
| Click(mouse.leftButton, queueEventOnly: true); | ||
|
|
||
| //mouse movements for higher polling mice (66*60 ~ 4kHz) | ||
|
||
| for (int j = 0; j < 66; ++j) | ||
| { | ||
| Move(mouse.position, new Vector2(i + j, i + j), queueEventOnly: true); | ||
| } | ||
|
|
||
| InputSystem.Update(); | ||
|
|
||
| yield return null; | ||
| } | ||
| } | ||
| } | ||
|
|
||
| [PrebuildSetup(typeof(ProjectWideActionsBuildSetup))] | ||
| [PostBuildCleanup(typeof(ProjectWideActionsBuildSetup))] | ||
| [UnityTest, Performance] | ||
| [Category("Performance")] | ||
| public IEnumerator Performance_MeasureInputSystemFrameTimeWithProfilerMarkers_DoingNothing() | ||
| { | ||
| string[] markers = | ||
| { | ||
| "InputUpdate", | ||
| "InputSystem.onBeforeUpdate", | ||
| "InputSystem.onAfterUpdate", | ||
| "PreUpdate.NewInputUpdate", | ||
| "PreUpdate.InputForUIUpdate", | ||
| "FixedUpdate.NewInputFixedUpdate" | ||
| }; | ||
|
|
||
| yield return Measure.Frames() | ||
| .WarmupCount(30) | ||
| .DontRecordFrametime() | ||
| .MeasurementCount(500) | ||
| .ProfilerMarkers(markers) | ||
| .Run(); | ||
| } | ||
|
|
||
| #endif | ||
| } | ||
Uh oh!
There was an error while loading. Please reload this page.