Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
67 changes: 66 additions & 1 deletion Assets/Tests/InputSystem/CorePerformanceTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1126,8 +1126,9 @@ public void Performance_OptimizedControls_ReadingPose4kTimes(OptimizationTestTyp

[PrebuildSetup(typeof(ProjectWideActionsBuildSetup))]
[PostBuildCleanup(typeof(ProjectWideActionsBuildSetup))]
[UnityTest, Performance]
[UnityTest, Performance, Version("2")]
[Category("Performance")]
// Simulate a FPS controller with WASD, mouse look and various key presses triggering actions
public IEnumerator Performance_MeasureInputSystemFrameTimeWithProfilerMarkers_FPS()
{
var keyboard = InputSystem.AddDevice<Keyboard>();
Expand Down Expand Up @@ -1169,6 +1170,7 @@ public IEnumerator Performance_MeasureInputSystemFrameTimeWithProfilerMarkers_FP
{
if (i % 60 == 0)
{
PressAndRelease(keyboard.wKey, queueEventOnly: true);
PressAndRelease(keyboard.aKey, queueEventOnly: true);
PressAndRelease(keyboard.sKey, queueEventOnly: true);
PressAndRelease(keyboard.dKey, queueEventOnly: true);
Expand Down Expand Up @@ -1207,5 +1209,68 @@ public IEnumerator Performance_MeasureInputSystemFrameTimeWithProfilerMarkers_Do
.Run();
}

[PrebuildSetup(typeof(ProjectWideActionsBuildSetup))]
[PostBuildCleanup(typeof(ProjectWideActionsBuildSetup))]
[UnityTest, Performance]
[Category("Performance")]
// Simulate a touch FPS controller with one constantly moving touch as the WASD equivalent
// and taps/clicks for button presses. Actions from PWA getting triggered.
public IEnumerator Performance_MeasureInputSystemFrameTimeWithProfilerMarkers_Touch()
{
var touchscreen = InputSystem.AddDevice<Touchscreen>();
EnhancedTouchSupport.Enable();

var clickAction = InputSystem.actions.FindAction("Click");
var pointAction = InputSystem.actions.FindAction("Point");

int performedCallCount = 0;

clickAction.performed += context => {
performedCallCount++;
};

pointAction.performed += context => {
performedCallCount++;
};

using (Measure.ProfilerMarkers(allInputSystemProfilerMarkers))
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess changes look ok here but I wonder what scenario we are trying to replicate here? It seems that there is not many touch points per frame here, essentially looks like one touch update per frame. That is fine given a e.g. 30 or 60 Hz touch sensor , but I believe most these days generate higher frequency of touch. It might be meaningful to measure a decently modern touch screen and take the actual achievable frequency. I wouldn't trust just reading specs since the HW frequency might be higher than what you get out of the driver.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It be good to outline the intended scenario as clearly as possible in the test description or inline (Seems like @jfreire-unity suggested something similar.

{
// start touch 1
BeginTouch(1, new Vector2(0.1f, 0.2f), queueEventOnly: true);

for (int i = 0; i < 500; ++i)
{
// start touch 2
BeginTouch(2, new Vector2(0.3f, 0.4f), queueEventOnly: true);
MoveTouch(2, new Vector2(0.3f + i, 0.4f + i), queueEventOnly: true);

// tap touch 3 once per frame
BeginTouch(3, new Vector2(0.5f, 0.6f), queueEventOnly: true);
MoveTouch(3, new Vector2(0.5f + i, 0.6f + i), queueEventOnly: true);
EndTouch(3, new Vector2(0.7f, 0.7f), queueEventOnly: true);

if (i % 60 == 0)
{
// end and restart touch 2 every 30 frames
EndTouch(2, new Vector2(0.9f, 0.9f), queueEventOnly: true);
BeginTouch(2, new Vector2(0.3f, 0.4f), queueEventOnly: true);
}

// move touch 1 with higher frequency assuming higher touch sampling rate then frames drawn
// 60Hz screen refresh rate & 260+ Hz touch sampling rate
for (int j = 1; j <= 5; j++)
{
MoveTouch(1, new Vector2(0.1f + j, 0.2f + j), queueEventOnly: true);
}

InputSystem.Update();

yield return null;
}
}

EnhancedTouchSupport.Disable();
}

#endif
}