@@ -60,9 +60,10 @@ Sampler = Utilities.createClass(
60
60
}
61
61
} ) ;
62
62
63
- const sampleTimeIndex = 0 ;
64
- const sampleComplexityIndex = 1 ;
65
- const sampleFrameLengthEstimateIndex = 2 ;
63
+ const sampleTypeIndex = 0 ;
64
+ const sampleTimeIndex = 1 ;
65
+ const sampleComplexityIndex = 2 ;
66
+ const sampleFrameLengthEstimateIndex = 3 ;
66
67
67
68
Controller = Utilities . createClass (
68
69
function ( benchmark , options )
@@ -74,7 +75,7 @@ Controller = Utilities.createClass(
74
75
this . _targetFrameRate = options [ "frame-rate" ] ;
75
76
// Default data series: timestamp, complexity, estimatedFrameLength
76
77
var sampleSize = options [ "sample-capacity" ] || ( this . _targetFrameRate * options [ "test-interval" ] / 1000 ) ;
77
- this . _sampler = new Sampler ( options [ "series-count" ] || 3 , sampleSize , this ) ;
78
+ this . _sampler = new Sampler ( options [ "series-count" ] || 4 , sampleSize , this ) ;
78
79
this . _marks = { } ;
79
80
80
81
this . _frameLengthEstimator = new SimpleKalmanEstimator ( options [ "kalman-process-error" ] , options [ "kalman-measurement-error" ] ) ;
@@ -102,7 +103,7 @@ Controller = Utilities.createClass(
102
103
103
104
recordFirstSample : function ( startTimestamp , stage )
104
105
{
105
- this . _sampler . record ( startTimestamp , stage . complexity ( ) , - 1 ) ;
106
+ this . _sampler . record ( Strings . json . mutationFrameType , startTimestamp , stage . complexity ( ) , - 1 ) ;
106
107
this . mark ( Strings . json . samplingStartTimeOffset , startTimestamp ) ;
107
108
} ,
108
109
@@ -156,6 +157,7 @@ Controller = Utilities.createClass(
156
157
157
158
update : function ( timestamp , stage )
158
159
{
160
+ const frameType = this . _previousFrameComplexity ( this . _sampler . samples , this . _sampler . sampleCount ) != stage . complexity ( ) ? Strings . json . mutationFrameType : Strings . json . animationFrameType
159
161
var lastFrameLength = timestamp - this . _previousTimestamp ;
160
162
this . _previousTimestamp = timestamp ;
161
163
@@ -166,7 +168,7 @@ Controller = Utilities.createClass(
166
168
this . _frameLengthEstimator . sample ( lastFrameLength ) ;
167
169
frameLengthEstimate = this . _frameLengthEstimator . estimate ;
168
170
}
169
- this . _sampler . record ( timestamp , stage . complexity ( ) , frameLengthEstimate ) ;
171
+ this . _sampler . record ( frameType , timestamp , stage . complexity ( ) , frameLengthEstimate ) ;
170
172
} else {
171
173
this . registerFrameTime ( lastFrameLength ) ;
172
174
if ( this . intervalHasConcluded ( timestamp ) ) {
@@ -176,13 +178,13 @@ Controller = Utilities.createClass(
176
178
this . _frameLengthEstimator . sample ( intervalAverageFrameLength ) ;
177
179
frameLengthEstimate = this . _frameLengthEstimator . estimate ;
178
180
}
179
- this . _sampler . record ( timestamp , stage . complexity ( ) , frameLengthEstimate ) ;
181
+ this . _sampler . record ( frameType , timestamp , stage . complexity ( ) , frameLengthEstimate ) ;
180
182
181
183
didFinishInterval = true ;
182
184
this . didFinishInterval ( timestamp , stage , intervalAverageFrameLength ) ;
183
185
this . _frameLengthEstimator . reset ( ) ;
184
186
} else
185
- this . _sampler . record ( timestamp , stage . complexity ( ) , frameLengthEstimate ) ;
187
+ this . _sampler . record ( frameType , timestamp , stage . complexity ( ) , frameLengthEstimate ) ;
186
188
}
187
189
188
190
this . tune ( timestamp , stage , lastFrameLength , didFinishInterval , intervalAverageFrameLength ) ;
@@ -231,12 +233,14 @@ Controller = Utilities.createClass(
231
233
232
234
_processControllerSamples : function ( )
233
235
{
234
- const processedSampleTimeIndex = 0 ;
235
- const processedSampleComplexityIndex = 1 ;
236
- const processedSampleFrameLengthIndex = 2 ;
237
- const processedSampleSmoothedFrameLengthIndex = 3 ;
236
+ const processedSampleTypeIndex = 0 ;
237
+ const processedSampleTimeIndex = 1 ;
238
+ const processedSampleComplexityIndex = 2 ;
239
+ const processedSampleFrameLengthIndex = 3 ;
240
+ const processedSampleSmoothedFrameLengthIndex = 4 ;
238
241
239
242
var controllerSamples = new SampleData ;
243
+ controllerSamples . addField ( Strings . json . frameType , processedSampleTypeIndex ) ;
240
244
controllerSamples . addField ( Strings . json . time , processedSampleTimeIndex ) ;
241
245
controllerSamples . addField ( Strings . json . complexity , processedSampleComplexityIndex ) ;
242
246
@@ -249,6 +253,7 @@ Controller = Utilities.createClass(
249
253
controllerSamples . push ( sample ) ;
250
254
251
255
// Represent time in milliseconds
256
+ controllerSamples . setFieldInDatum ( sample , Strings . json . frameType , samples [ sampleTypeIndex ] [ i ] ) ;
252
257
controllerSamples . setFieldInDatum ( sample , Strings . json . time , timestamp - this . _startTimestamp ) ;
253
258
controllerSamples . setFieldInDatum ( sample , Strings . json . complexity , samples [ sampleComplexityIndex ] [ i ] ) ;
254
259
@@ -316,7 +321,7 @@ AdaptiveController = Utilities.createSubclass(Controller,
316
321
317
322
recordFirstSample : function ( startTimestamp , stage )
318
323
{
319
- this . _sampler . record ( startTimestamp , stage . complexity ( ) , - 1 ) ;
324
+ this . _sampler . record ( Strings . json . mutationFrameType , startTimestamp , stage . complexity ( ) , - 1 ) ;
320
325
} ,
321
326
322
327
update : function ( timestamp , stage )
@@ -330,7 +335,7 @@ AdaptiveController = Utilities.createSubclass(Controller,
330
335
++ this . _intervalFrameCount ;
331
336
332
337
if ( this . _intervalFrameCount < this . _numberOfFramesToMeasurePerInterval ) {
333
- this . _sampler . record ( timestamp , stage . complexity ( ) , - 1 ) ;
338
+ this . _sampler . record ( Strings . json . animationFrameType , timestamp , stage . complexity ( ) , - 1 ) ;
334
339
return ;
335
340
}
336
341
@@ -342,7 +347,7 @@ AdaptiveController = Utilities.createSubclass(Controller,
342
347
tuneValue = tuneValue > 0 ? Math . floor ( tuneValue ) : Math . ceil ( tuneValue ) ;
343
348
stage . tune ( tuneValue ) ;
344
349
345
- this . _sampler . record ( timestamp , stage . complexity ( ) , this . _frameLengthEstimator . estimate ) ;
350
+ this . _sampler . record ( Strings . json . mutationFrameType , timestamp , stage . complexity ( ) , this . _frameLengthEstimator . estimate ) ;
346
351
347
352
// Start the next interval.
348
353
this . _intervalFrameCount = 0 ;
@@ -551,8 +556,11 @@ RampController = Utilities.createSubclass(Controller,
551
556
}
552
557
553
558
var regressionData = [ ] ;
554
- for ( var i = this . _rampStartIndex ; i < this . _sampler . sampleCount ; ++ i )
559
+ for ( var i = this . _rampStartIndex ; i < this . _sampler . sampleCount ; ++ i ) {
560
+ if ( this . _getFrameType ( this . _sampler . samples , i ) == Strings . json . mutationFrameType )
561
+ continue ;
555
562
regressionData . push ( [ this . _getComplexity ( this . _sampler . samples , i ) , this . _getFrameLength ( this . _sampler . samples , i ) ] ) ;
563
+ }
556
564
557
565
var regression = new Regression ( regressionData , this . _sampler . sampleCount - 1 , this . _rampStartIndex , { desiredFrameLength : this . frameLengthDesired } ) ;
558
566
this . _rampRegressions . push ( regression ) ;
@@ -590,6 +598,11 @@ RampController = Utilities.createSubclass(Controller,
590
598
this . _possibleMaximumComplexity = this . _maximumComplexity ;
591
599
} ,
592
600
601
+ _getFrameType : function ( samples , i )
602
+ {
603
+ return samples [ sampleTypeIndex ] [ i ] ;
604
+ } ,
605
+
593
606
_getComplexity : function ( samples , i )
594
607
{
595
608
return samples [ sampleComplexityIndex ] [ i ] ;
@@ -599,6 +612,14 @@ RampController = Utilities.createSubclass(Controller,
599
612
{
600
613
return samples [ sampleTimeIndex ] [ i ] - samples [ sampleTimeIndex ] [ i - 1 ] ;
601
614
} ,
615
+
616
+ _previousFrameComplexity : function ( samples , currentSampleCount )
617
+ {
618
+ if ( currentSampleCount > 0 )
619
+ return this . _getComplexity ( samples , currentSampleCount - 1 ) ;
620
+
621
+ return 0 ;
622
+ } ,
602
623
603
624
processSamples : function ( results )
604
625
{
0 commit comments