@@ -110,33 +110,14 @@ Controller = Utilities.createClass(
110110 return comment in this . _marks ;
111111 } ,
112112
113- filterOutOutliers : function ( array )
114- {
115- if ( array . length == 0 )
116- return [ ] ;
117-
118- array . sort ( ) ;
119- var q1 = array [ Math . min ( Math . round ( array . length * 1 / 4 ) , array . length - 1 ) ] ;
120- var q3 = array [ Math . min ( Math . round ( array . length * 3 / 4 ) , array . length - 1 ) ] ;
121- var interquartileRange = q3 - q1 ;
122- var minimum = q1 - interquartileRange * 1.5 ;
123- var maximum = q3 + interquartileRange * 1.5 ;
124- return array . filter ( x => x >= minimum && x <= maximum ) ;
125- } ,
126-
127113 _measureAndResetInterval : function ( currentTimestamp )
128114 {
129115 var sampleCount = this . _sampler . sampleCount ;
130116 var averageFrameLength = 0 ;
131117
132118 if ( this . _intervalEndTimestamp ) {
133- var durations = [ ] ;
134- for ( var i = Math . max ( this . _intervalStartIndex , 1 ) ; i < sampleCount ; ++ i ) {
135- durations . push ( this . _sampler . samples [ 0 ] [ i ] - this . _sampler . samples [ 0 ] [ i - 1 ] ) ;
136- }
137- var filteredDurations = this . filterOutOutliers ( durations ) ;
138- if ( filteredDurations . length > 0 )
139- averageFrameLength = filteredDurations . reduce ( ( a , b ) => a + b , 0 ) / filteredDurations . length ;
119+ var intervalStartTimestamp = this . _sampler . samples [ 0 ] [ this . _intervalStartIndex ] ;
120+ averageFrameLength = ( currentTimestamp - intervalStartTimestamp ) / ( sampleCount - this . _intervalStartIndex ) ;
140121 }
141122
142123 this . _intervalStartIndex = sampleCount ;
@@ -157,34 +138,21 @@ Controller = Utilities.createClass(
157138 this . _frameLengthEstimator . sample ( lastFrameLength ) ;
158139 frameLengthEstimate = this . _frameLengthEstimator . estimate ;
159140 }
160- } else {
161- this . registerFrameTime ( lastFrameLength ) ;
162- if ( this . intervalHasConcluded ( timestamp ) ) {
163- var intervalStartTimestamp = this . _sampler . samples [ 0 ] [ this . _intervalStartIndex ] ;
164- intervalAverageFrameLength = this . _measureAndResetInterval ( timestamp ) ;
165- if ( this . _isFrameLengthEstimatorEnabled ) {
166- this . _frameLengthEstimator . sample ( intervalAverageFrameLength ) ;
167- frameLengthEstimate = this . _frameLengthEstimator . estimate ;
168- }
169- didFinishInterval = true ;
170- this . didFinishInterval ( timestamp , stage , intervalAverageFrameLength ) ;
171- this . _frameLengthEstimator . reset ( ) ;
141+ } else if ( timestamp >= this . _intervalEndTimestamp ) {
142+ var intervalStartTimestamp = this . _sampler . samples [ 0 ] [ this . _intervalStartIndex ] ;
143+ intervalAverageFrameLength = this . _measureAndResetInterval ( timestamp ) ;
144+ if ( this . _isFrameLengthEstimatorEnabled ) {
145+ this . _frameLengthEstimator . sample ( intervalAverageFrameLength ) ;
146+ frameLengthEstimate = this . _frameLengthEstimator . estimate ;
172147 }
148+ didFinishInterval = true ;
149+ this . didFinishInterval ( timestamp , stage , intervalAverageFrameLength ) ;
173150 }
174151
175152 this . _sampler . record ( timestamp , stage . complexity ( ) , frameLengthEstimate ) ;
176153 this . tune ( timestamp , stage , lastFrameLength , didFinishInterval , intervalAverageFrameLength ) ;
177154 } ,
178155
179- registerFrameTime : function ( lastFrameLength )
180- {
181- } ,
182-
183- intervalHasConcluded : function ( timestamp )
184- {
185- return timestamp >= this . _intervalEndTimestamp ;
186- } ,
187-
188156 didFinishInterval : function ( timestamp , stage , intervalAverageFrameLength )
189157 {
190158 } ,
@@ -368,8 +336,6 @@ RampController = Utilities.createSubclass(Controller,
368336 tierFastTestLength : 250 ,
369337 // If the engine is under stress, let the test run a little longer to let the measurement settle
370338 tierSlowTestLength : 750 ,
371- // Tier intervals must have this number of non-outlier frames in order to end.
372- numberOfFramesRequiredInInterval : 9 ,
373339
374340 rampWarmupLength : 200 ,
375341
@@ -389,25 +355,10 @@ RampController = Utilities.createSubclass(Controller,
389355 Controller . prototype . start . call ( this , startTimestamp , stage ) ;
390356 this . _rampStartTimestamp = 0 ;
391357 this . intervalSamplingLength = 100 ;
392- this . _frameTimeHistory = [ ] ;
393- } ,
394-
395- registerFrameTime : function ( lastFrameLength )
396- {
397- this . _frameTimeHistory . push ( lastFrameLength ) ;
398- } ,
399-
400- intervalHasConcluded : function ( timestamp )
401- {
402- if ( ! Controller . prototype . intervalHasConcluded . call ( this , timestamp ) )
403- return false ;
404-
405- return this . _finishedTierSampling || this . filterOutOutliers ( this . _frameTimeHistory ) . length > this . numberOfFramesRequiredInInterval ;
406358 } ,
407359
408360 didFinishInterval : function ( timestamp , stage , intervalAverageFrameLength )
409361 {
410- this . _frameTimeHistory = [ ] ;
411362 if ( ! this . _finishedTierSampling ) {
412363 if ( this . _tierStartTimestamp > 0 && timestamp < this . _tierStartTimestamp + this . tierFastTestLength )
413364 return ;
0 commit comments