@@ -59,6 +59,10 @@ Sampler = Utilities.createClass(
59
59
}
60
60
} ) ;
61
61
62
+ const sampleTimeIndex = 0 ;
63
+ const sampleComplexityIndex = 1 ;
64
+ const sampleFrameLengthEstimateIndex = 2 ;
65
+
62
66
Controller = Utilities . createClass (
63
67
function ( benchmark , options )
64
68
{
@@ -136,7 +140,7 @@ Controller = Utilities.createClass(
136
140
if ( this . _intervalEndTimestamp ) {
137
141
var durations = [ ] ;
138
142
for ( var i = Math . max ( this . _intervalStartIndex , 1 ) ; i < sampleCount ; ++ i ) {
139
- durations . push ( this . _sampler . samples [ 0 ] [ i ] - this . _sampler . samples [ 0 ] [ i - 1 ] ) ;
143
+ durations . push ( this . _sampler . samples [ sampleTimeIndex ] [ i ] - this . _sampler . samples [ sampleTimeIndex ] [ i - 1 ] ) ;
140
144
}
141
145
var filteredDurations = this . filterOutOutliers ( durations ) ;
142
146
if ( filteredDurations . length > 0 )
@@ -164,7 +168,7 @@ Controller = Utilities.createClass(
164
168
} else {
165
169
this . registerFrameTime ( lastFrameLength ) ;
166
170
if ( this . intervalHasConcluded ( timestamp ) ) {
167
- var intervalStartTimestamp = this . _sampler . samples [ 0 ] [ this . _intervalStartIndex ] ;
171
+ var intervalStartTimestamp = this . _sampler . samples [ sampleTimeIndex ] [ this . _intervalStartIndex ] ;
168
172
intervalAverageFrameLength = this . _measureAndResetInterval ( timestamp ) ;
169
173
if ( this . _isFrameLengthEstimatorEnabled ) {
170
174
this . _frameLengthEstimator . sample ( intervalAverageFrameLength ) ;
@@ -223,28 +227,34 @@ Controller = Utilities.createClass(
223
227
224
228
_processControllerSamples : function ( )
225
229
{
230
+ const processedSampleTimeIndex = 0 ;
231
+ const processedSampleComplexityIndex = 1 ;
232
+ const processedSampleFrameLengthIndex = 2 ;
233
+ const processedSampleSmoothedFrameLengthIndex = 3 ;
234
+
226
235
var controllerSamples = new SampleData ;
227
- controllerSamples . addField ( Strings . json . time , 0 ) ;
228
- controllerSamples . addField ( Strings . json . complexity , 1 ) ;
229
- controllerSamples . addField ( Strings . json . frameLength , 2 ) ;
230
- controllerSamples . addField ( Strings . json . smoothedFrameLength , 3 ) ;
236
+ controllerSamples . addField ( Strings . json . time , processedSampleTimeIndex ) ;
237
+ controllerSamples . addField ( Strings . json . complexity , processedSampleComplexityIndex ) ;
238
+
239
+ controllerSamples . addField ( Strings . json . frameLength , processedSampleFrameLengthIndex ) ;
240
+ controllerSamples . addField ( Strings . json . smoothedFrameLength , processedSampleSmoothedFrameLengthIndex ) ;
231
241
232
242
var samples = this . _sampler . samples ;
233
- samples [ 0 ] . forEach ( function ( timestamp , i ) {
243
+ samples [ sampleTimeIndex ] . forEach ( function ( timestamp , i ) {
234
244
var sample = controllerSamples . createDatum ( ) ;
235
245
controllerSamples . push ( sample ) ;
236
246
237
247
// Represent time in milliseconds
238
248
controllerSamples . setFieldInDatum ( sample , Strings . json . time , timestamp - this . _startTimestamp ) ;
239
- controllerSamples . setFieldInDatum ( sample , Strings . json . complexity , samples [ 1 ] [ i ] ) ;
249
+ controllerSamples . setFieldInDatum ( sample , Strings . json . complexity , samples [ sampleComplexityIndex ] [ i ] ) ;
240
250
241
251
if ( i == 0 )
242
252
controllerSamples . setFieldInDatum ( sample , Strings . json . frameLength , 1000 / this . _targetFrameRate ) ;
243
253
else
244
- controllerSamples . setFieldInDatum ( sample , Strings . json . frameLength , timestamp - samples [ 0 ] [ i - 1 ] ) ;
254
+ controllerSamples . setFieldInDatum ( sample , Strings . json . frameLength , timestamp - samples [ sampleTimeIndex ] [ i - 1 ] ) ;
245
255
246
- if ( samples [ 2 ] [ i ] != - 1 )
247
- controllerSamples . setFieldInDatum ( sample , Strings . json . smoothedFrameLength , samples [ 2 ] [ i ] ) ;
256
+ if ( samples [ sampleFrameLengthEstimateIndex ] [ i ] != - 1 )
257
+ controllerSamples . setFieldInDatum ( sample , Strings . json . smoothedFrameLength , samples [ sampleFrameLengthEstimateIndex ] [ i ] ) ;
248
258
} , this ) ;
249
259
250
260
return controllerSamples ;
@@ -544,7 +554,7 @@ RampController = Utilities.createSubclass(Controller,
544
554
if ( frameLengthAtMaxComplexity < this . frameLengthRampLowerThreshold )
545
555
this . _possibleMaximumComplexity = Math . floor ( Utilities . lerp ( Utilities . progressValue ( this . frameLengthRampLowerThreshold , frameLengthAtMaxComplexity , this . _lastTierFrameLength ) , this . _maximumComplexity , this . _lastTierComplexity ) ) ;
546
556
// If the regression doesn't fit the first segment at all, keep the minimum bound at 1
547
- if ( ( timestamp - this . _sampler . samples [ 0 ] [ this . _sampler . sampleCount - regression . n1 ] ) / this . _currentRampLength < .25 )
557
+ if ( ( timestamp - this . _sampler . samples [ sampleTimeIndex ] [ this . _sampler . sampleCount - regression . n1 ] ) / this . _currentRampLength < .25 )
548
558
this . _possibleMinimumComplexity = 1 ;
549
559
550
560
this . _minimumComplexityEstimator . sample ( this . _possibleMinimumComplexity ) ;
@@ -575,12 +585,12 @@ RampController = Utilities.createSubclass(Controller,
575
585
576
586
_getComplexity : function ( samples , i )
577
587
{
578
- return samples [ 1 ] [ i ] ;
588
+ return samples [ sampleComplexityIndex ] [ i ] ;
579
589
} ,
580
590
581
591
_getFrameLength : function ( samples , i )
582
592
{
583
- return samples [ 0 ] [ i ] - samples [ 0 ] [ i - 1 ] ;
593
+ return samples [ sampleTimeIndex ] [ i ] - samples [ sampleTimeIndex ] [ i - 1 ] ;
584
594
} ,
585
595
586
596
processSamples : function ( results )
0 commit comments