@@ -1126,8 +1126,9 @@ public void Performance_OptimizedControls_ReadingPose4kTimes(OptimizationTestTyp
11261126
11271127 [ PrebuildSetup ( typeof ( ProjectWideActionsBuildSetup ) ) ]
11281128 [ PostBuildCleanup ( typeof ( ProjectWideActionsBuildSetup ) ) ]
1129- [ UnityTest , Performance ]
1129+ [ UnityTest , Performance , Version ( "2" ) ]
11301130 [ Category ( "Performance" ) ]
1131+ // Simulate a FPS controller with WASD, mouse look and various key presses triggering actions
11311132 public IEnumerator Performance_MeasureInputSystemFrameTimeWithProfilerMarkers_FPS ( )
11321133 {
11331134 var keyboard = InputSystem . AddDevice < Keyboard > ( ) ;
@@ -1169,6 +1170,7 @@ public IEnumerator Performance_MeasureInputSystemFrameTimeWithProfilerMarkers_FP
11691170 {
11701171 if ( i % 60 == 0 )
11711172 {
1173+ PressAndRelease ( keyboard . wKey , queueEventOnly : true ) ;
11721174 PressAndRelease ( keyboard . aKey , queueEventOnly : true ) ;
11731175 PressAndRelease ( keyboard . sKey , queueEventOnly : true ) ;
11741176 PressAndRelease ( keyboard . dKey , queueEventOnly : true ) ;
@@ -1207,5 +1209,68 @@ public IEnumerator Performance_MeasureInputSystemFrameTimeWithProfilerMarkers_Do
12071209 . Run ( ) ;
12081210 }
12091211
1212+ [ PrebuildSetup ( typeof ( ProjectWideActionsBuildSetup ) ) ]
1213+ [ PostBuildCleanup ( typeof ( ProjectWideActionsBuildSetup ) ) ]
1214+ [ UnityTest , Performance ]
1215+ [ Category ( "Performance" ) ]
1216+ // Simulate a touch FPS controller with one constantly moving touch as the WASD equivalent
1217+ // and taps/clicks for button presses. Actions from PWA getting triggered.
1218+ public IEnumerator Performance_MeasureInputSystemFrameTimeWithProfilerMarkers_Touch ( )
1219+ {
1220+ var touchscreen = InputSystem . AddDevice < Touchscreen > ( ) ;
1221+ EnhancedTouchSupport . Enable ( ) ;
1222+
1223+ var clickAction = InputSystem . actions . FindAction ( "Click" ) ;
1224+ var pointAction = InputSystem . actions . FindAction ( "Point" ) ;
1225+
1226+ int performedCallCount = 0 ;
1227+
1228+ clickAction . performed += context => {
1229+ performedCallCount ++ ;
1230+ } ;
1231+
1232+ pointAction . performed += context => {
1233+ performedCallCount ++ ;
1234+ } ;
1235+
1236+ using ( Measure . ProfilerMarkers ( allInputSystemProfilerMarkers ) )
1237+ {
1238+ // start touch 1
1239+ BeginTouch ( 1 , new Vector2 ( 0.1f , 0.2f ) , queueEventOnly : true ) ;
1240+
1241+ for ( int i = 0 ; i < 500 ; ++ i )
1242+ {
1243+ // start touch 2
1244+ BeginTouch ( 2 , new Vector2 ( 0.3f , 0.4f ) , queueEventOnly : true ) ;
1245+ MoveTouch ( 2 , new Vector2 ( 0.3f + i , 0.4f + i ) , queueEventOnly : true ) ;
1246+
1247+ // tap touch 3 once per frame
1248+ BeginTouch ( 3 , new Vector2 ( 0.5f , 0.6f ) , queueEventOnly : true ) ;
1249+ MoveTouch ( 3 , new Vector2 ( 0.5f + i , 0.6f + i ) , queueEventOnly : true ) ;
1250+ EndTouch ( 3 , new Vector2 ( 0.7f , 0.7f ) , queueEventOnly : true ) ;
1251+
1252+ if ( i % 60 == 0 )
1253+ {
1254+ // end and restart touch 2 every 30 frames
1255+ EndTouch ( 2 , new Vector2 ( 0.9f , 0.9f ) , queueEventOnly : true ) ;
1256+ BeginTouch ( 2 , new Vector2 ( 0.3f , 0.4f ) , queueEventOnly : true ) ;
1257+ }
1258+
1259+ // move touch 1 with higher frequency assuming higher touch sampling rate then frames drawn
1260+ // 60Hz screen refresh rate & 260+ Hz touch sampling rate
1261+ for ( int j = 1 ; j <= 5 ; j ++ )
1262+ {
1263+ MoveTouch ( 1 , new Vector2 ( 0.1f + j , 0.2f + j ) , queueEventOnly : true ) ;
1264+ }
1265+
1266+ InputSystem . Update ( ) ;
1267+
1268+ yield return null ;
1269+ }
1270+ }
1271+
1272+ EnhancedTouchSupport . Disable ( ) ;
1273+ }
1274+
12101275 #endif
12111276}
0 commit comments