11
11
12
12
namespace Benchmarking
13
13
{
14
+ public enum BenchmarkType
15
+ {
16
+ UseTimeDuration ,
17
+ UseTimelineInTheScene ,
18
+ }
14
19
[ Serializable ]
15
20
public class PerformanceTestStage
16
21
{
@@ -19,8 +24,8 @@ public class PerformanceTestStage
19
24
[ FormerlySerializedAs ( "SceneName" ) ]
20
25
public string sceneName ;
21
26
22
- public bool useFullTimeline = true ;
23
- // ENDTODO
27
+ public BenchmarkType benchmarkType = BenchmarkType . UseTimelineInTheScene ;
28
+ public int timeDuration = 30 ;
24
29
25
30
private List < FrameData > _frameDatas ;
26
31
private FrameData _minFrameData , _maxFrameData , _avgFrameData , _medianFrameData , _lowerQuartileFrameData , _upperQuartileFrameData ;
@@ -29,7 +34,6 @@ public class PerformanceTestStage
29
34
30
35
private Action _finishedAction ;
31
36
private PlayableDirector _playableDirector ;
32
- private float _intermediateCaptureTime ;
33
37
34
38
private bool _uiInitialized = false ;
35
39
private VisualElement
@@ -265,13 +269,13 @@ async Awaitable LoadAndInitAsync()
265
269
else if ( directors . Length > 0 )
266
270
_playableDirector = directors [ 0 ] ;
267
271
268
- if ( directors . Length <= 0 )
272
+ if ( directors . Length <= 0 || benchmarkType == BenchmarkType . UseTimeDuration )
269
273
{
270
274
// create dummy PlayableAsset with benchmarkDuration
271
275
var timelineAsset = ScriptableObject . CreateInstance < TimelineAsset > ( ) ;
272
276
var track = timelineAsset . CreateTrack < ControlTrack > ( null , "Control Track" ) ;
273
277
var clip = track . CreateDefaultClip ( ) ;
274
- clip . duration = 30 ;
278
+ clip . duration = timeDuration ;
275
279
276
280
_playableDirector = new GameObject ( "CinematicTimeline" ) . AddComponent < PlayableDirector > ( ) ;
277
281
_playableDirector . playableAsset = timelineAsset ;
@@ -280,9 +284,6 @@ async Awaitable LoadAndInitAsync()
280
284
if ( _playableDirector != null )
281
285
{
282
286
_playableDirector . gameObject . SetActive ( true ) ;
283
-
284
- var duration = ( float ) _playableDirector . duration ;
285
- _intermediateCaptureTime = duration / ( PerformanceTest . instance . _framesToCapture + 1 ) ;
286
287
287
288
_playableDirector . Play ( ) ;
288
289
_playableDirector . extrapolationMode = DirectorWrapMode . None ;
@@ -291,9 +292,6 @@ async Awaitable LoadAndInitAsync()
291
292
}
292
293
293
294
// Init
294
- var initialListSize = PerformanceTest . instance . _framesToCapture ;
295
- if ( _playableDirector != null && useFullTimeline )
296
- initialListSize = ( int ) _playableDirector . duration * 120 ;
297
295
_recordingIndex = 0 ;
298
296
299
297
_frameDatas = new List < FrameData > ( ) ;
@@ -320,8 +318,7 @@ async Awaitable RunTestAsync()
320
318
_progressContainerVE . style . opacity = 1f ;
321
319
_progressLabel . text = "0" ;
322
320
_progressBarVe . style . width = 0 ;
323
-
324
- bool noIntermediateTime = useFullTimeline && _playableDirector != null ;
321
+
325
322
326
323
if ( _playableDirector != null )
327
324
{
@@ -330,11 +327,7 @@ async Awaitable RunTestAsync()
330
327
}
331
328
332
329
while (
333
- status != TestStageStatus . Stopped &&
334
- (
335
- useFullTimeline && _playableDirector != null &&
336
- _playableDirector . state != PlayState . Paused
337
- )
330
+ status != TestStageStatus . Stopped && _playableDirector . state != PlayState . Paused
338
331
)
339
332
{
340
333
FrameData currentFrameData = FrameData . GetCurrentFrameData ( ) ;
@@ -350,10 +343,7 @@ async Awaitable RunTestAsync()
350
343
_progressLabel . text = timerLineAdvancement . ToString ( ) ;
351
344
_progressBarVe . style . width = P ( timerLineAdvancement ) ;
352
345
353
- if ( noIntermediateTime )
354
- await Awaitable . EndOfFrameAsync ( ) ;
355
- else
356
- await Awaitable . WaitForSecondsAsync ( _intermediateCaptureTime ) ;
346
+ await Awaitable . EndOfFrameAsync ( ) ;
357
347
}
358
348
}
359
349
0 commit comments