1111
1212namespace Benchmarking
1313{
14+ public enum BenchmarkType
15+ {
16+ UseTimeDuration ,
17+ UseTimelineInTheScene ,
18+ }
1419 [ Serializable ]
1520 public class PerformanceTestStage
1621 {
@@ -19,8 +24,8 @@ public class PerformanceTestStage
1924 [ FormerlySerializedAs ( "SceneName" ) ]
2025 public string sceneName ;
2126
22- public bool useFullTimeline = true ;
23- // ENDTODO
27+ public BenchmarkType benchmarkType = BenchmarkType . UseTimelineInTheScene ;
28+ public int timeDuration = 30 ;
2429
2530 private List < FrameData > _frameDatas ;
2631 private FrameData _minFrameData , _maxFrameData , _avgFrameData , _medianFrameData , _lowerQuartileFrameData , _upperQuartileFrameData ;
@@ -29,7 +34,6 @@ public class PerformanceTestStage
2934
3035 private Action _finishedAction ;
3136 private PlayableDirector _playableDirector ;
32- private float _intermediateCaptureTime ;
3337
3438 private bool _uiInitialized = false ;
3539 private VisualElement
@@ -265,13 +269,13 @@ async Awaitable LoadAndInitAsync()
265269 else if ( directors . Length > 0 )
266270 _playableDirector = directors [ 0 ] ;
267271
268- if ( directors . Length <= 0 )
272+ if ( directors . Length <= 0 || benchmarkType == BenchmarkType . UseTimeDuration )
269273 {
270274 // create dummy PlayableAsset with benchmarkDuration
271275 var timelineAsset = ScriptableObject . CreateInstance < TimelineAsset > ( ) ;
272276 var track = timelineAsset . CreateTrack < ControlTrack > ( null , "Control Track" ) ;
273277 var clip = track . CreateDefaultClip ( ) ;
274- clip . duration = 30 ;
278+ clip . duration = timeDuration ;
275279
276280 _playableDirector = new GameObject ( "CinematicTimeline" ) . AddComponent < PlayableDirector > ( ) ;
277281 _playableDirector . playableAsset = timelineAsset ;
@@ -280,9 +284,6 @@ async Awaitable LoadAndInitAsync()
280284 if ( _playableDirector != null )
281285 {
282286 _playableDirector . gameObject . SetActive ( true ) ;
283-
284- var duration = ( float ) _playableDirector . duration ;
285- _intermediateCaptureTime = duration / ( PerformanceTest . instance . _framesToCapture + 1 ) ;
286287
287288 _playableDirector . Play ( ) ;
288289 _playableDirector . extrapolationMode = DirectorWrapMode . None ;
@@ -291,9 +292,6 @@ async Awaitable LoadAndInitAsync()
291292 }
292293
293294 // Init
294- var initialListSize = PerformanceTest . instance . _framesToCapture ;
295- if ( _playableDirector != null && useFullTimeline )
296- initialListSize = ( int ) _playableDirector . duration * 120 ;
297295 _recordingIndex = 0 ;
298296
299297 _frameDatas = new List < FrameData > ( ) ;
@@ -320,8 +318,7 @@ async Awaitable RunTestAsync()
320318 _progressContainerVE . style . opacity = 1f ;
321319 _progressLabel . text = "0" ;
322320 _progressBarVe . style . width = 0 ;
323-
324- bool noIntermediateTime = useFullTimeline && _playableDirector != null ;
321+
325322
326323 if ( _playableDirector != null )
327324 {
@@ -330,11 +327,7 @@ async Awaitable RunTestAsync()
330327 }
331328
332329 while (
333- status != TestStageStatus . Stopped &&
334- (
335- useFullTimeline && _playableDirector != null &&
336- _playableDirector . state != PlayState . Paused
337- )
330+ status != TestStageStatus . Stopped && _playableDirector . state != PlayState . Paused
338331 )
339332 {
340333 FrameData currentFrameData = FrameData . GetCurrentFrameData ( ) ;
@@ -350,10 +343,7 @@ async Awaitable RunTestAsync()
350343 _progressLabel . text = timerLineAdvancement . ToString ( ) ;
351344 _progressBarVe . style . width = P ( timerLineAdvancement ) ;
352345
353- if ( noIntermediateTime )
354- await Awaitable . EndOfFrameAsync ( ) ;
355- else
356- await Awaitable . WaitForSecondsAsync ( _intermediateCaptureTime ) ;
346+ await Awaitable . EndOfFrameAsync ( ) ;
357347 }
358348 }
359349
0 commit comments