@@ -13,10 +13,19 @@ bp.runState = {
13
13
timesPerAction : { }
14
14
} ;
15
15
16
+ bp . Statistics . getStabilityOfSample = function ( sample , confidenceRange ) {
17
+ var inRange = 0 ;
18
+ sample . forEach ( function ( x ) {
19
+ inRange += x <= confidenceRange [ 1 ] && x >= confidenceRange [ 0 ] ? 1 : 0 ;
20
+ } )
21
+ return Math . round ( ( inRange / sample . length ) * 100 ) / 100 ;
22
+
23
+ } ;
24
+
16
25
bp . Statistics . getConfidenceRange = function ( mean , confidenceInterval ) {
17
26
return [
18
- mean - confidenceInterval ,
19
- mean + confidenceInterval
27
+ Math . round ( ( mean - confidenceInterval ) * 100 ) / 100 ,
28
+ Math . round ( ( mean + confidenceInterval ) * 100 ) / 100
20
29
] ;
21
30
} ;
22
31
@@ -174,20 +183,18 @@ bp.runAllTests = function (done) {
174
183
}
175
184
176
185
bp . generateReportModel = function ( rawModel ) {
177
- return {
178
- name : rawModel . name ,
179
- avg : {
180
- time : ( '' + rawModel . avg . time ) . substr ( 0 , 6 ) ,
181
- gcTime : ( '' + rawModel . avg . gcTime ) . substr ( 0 , 6 ) ,
182
- garbage : ( '' + rawModel . avg . garbage ) . substr ( 0 , 6 ) ,
183
- retained : ( '' + rawModel . avg . retained ) . substr ( 0 , 6 ) ,
184
- combinedTime : ( '' + ( rawModel . avg . time + rawModel . avg . gcTime ) ) . substr ( 0 , 6 )
185
- } ,
186
- times : rawModel . times . join ( '<br>' ) ,
187
- gcTimes : rawModel . gcTimes . join ( '<br>' ) ,
188
- garbageTimes : rawModel . garbageTimes . join ( '<br>' ) ,
189
- retainedTimes : rawModel . retainedTimes . join ( '<br>' )
186
+ rawModel . avg = {
187
+ time : ( '' + rawModel . avg . time ) . substr ( 0 , 6 ) ,
188
+ gcTime : ( '' + rawModel . avg . gcTime ) . substr ( 0 , 6 ) ,
189
+ garbage : ( '' + rawModel . avg . garbage ) . substr ( 0 , 6 ) ,
190
+ retained : ( '' + rawModel . avg . retained ) . substr ( 0 , 6 ) ,
191
+ combinedTime : ( '' + ( rawModel . avg . time + rawModel . avg . gcTime ) ) . substr ( 0 , 6 )
190
192
} ;
193
+ rawModel . times = rawModel . times . join ( '<br>' ) ,
194
+ rawModel . gcTimes = rawModel . gcTimes . join ( '<br>' ) ,
195
+ rawModel . garbageTimes = rawModel . garbageTimes . join ( '<br>' ) ,
196
+ rawModel . retainedTimes = rawModel . retainedTimes . join ( '<br>' )
197
+ return rawModel ;
191
198
} ;
192
199
193
200
bp . generateReportPartial = function ( model ) {
@@ -261,7 +268,9 @@ bp.calcStats = function() {
261
268
retainedTimeForStep = bp . runState . recentRetainedMemoryPerStep [ stepName ] ,
262
269
tpa = bp . getTimesPerAction ( stepName ) ,
263
270
reportModel ,
264
- avg ;
271
+ avg ,
272
+ timesConfidenceInterval ,
273
+ timesConfidenceRange ;
265
274
266
275
bp . updateTimes ( tpa , tpa . nextEntry , 'gcTimes' , gcTimeForStep ) ;
267
276
bp . updateTimes ( tpa , tpa . nextEntry , 'garbageTimes' , garbageTimeForStep / 1e3 ) ;
@@ -275,10 +284,22 @@ bp.calcStats = function() {
275
284
tpa . gcTimes ,
276
285
tpa . garbageTimes ,
277
286
tpa . retainedTimes ) ;
287
+
288
+ timesConfidenceInterval = bp . Statistics . calculateConfidenceInterval (
289
+ bp . Statistics . calculateStandardDeviation ( tpa . times ) ,
290
+ tpa . times . length
291
+ ) ;
292
+ timesConfidenceRange = bp . Statistics . getConfidenceRange (
293
+ avg . time ,
294
+ timesConfidenceInterval
295
+ ) ;
278
296
reportModel = bp . generateReportModel ( {
279
297
name : stepName ,
280
298
avg : avg ,
281
299
times : tpa . fmtTimes ,
300
+ timesConfidenceInterval : timesConfidenceInterval ,
301
+ timesConfidenceRange : timesConfidenceRange ,
302
+ timesStability : bp . Statistics . getStabilityOfSample ( tpa . times , timesConfidenceRange ) * 100 ,
282
303
gcTimes : tpa . fmtGcTimes ,
283
304
garbageTimes : tpa . fmtGarbageTimes ,
284
305
retainedTimes : tpa . fmtRetainedTimes
0 commit comments