@@ -15,7 +15,9 @@ var bp = window.bp = {
15
15
Report : {
16
16
timesPerAction : { }
17
17
} ,
18
- Measure : { }
18
+ Measure : {
19
+ characteristics : [ 'gcTime' , 'testTime' , 'garbageCount' , 'retainedCount' ]
20
+ }
19
21
} ;
20
22
21
23
bp . Measure . numMilliseconds = function ( ) {
@@ -151,8 +153,8 @@ bp.Runner.runTimedTest = function (bs) {
151
153
testTime : endTime ,
152
154
gcTime : endGCTime ,
153
155
beforeHeap : beforeHeap ,
154
- garbage : garbage ,
155
- retainedMemory : retainedMemory
156
+ garbageCount : garbage ,
157
+ retainedCount : retainedMemory
156
158
} ;
157
159
} ;
158
160
@@ -168,12 +170,16 @@ bp.Report.getTimesPerAction = function(name) {
168
170
var tpa = bp . Report . timesPerAction [ name ] ;
169
171
if ( ! tpa ) {
170
172
tpa = bp . Report . timesPerAction [ name ] = {
171
- testTimes : [ ] , // circular buffer
172
- gcTimes : [ ] ,
173
- garbageCount : [ ] ,
174
- retainedCount : [ ] ,
173
+ name : name ,
175
174
nextEntry : 0
176
- }
175
+ } ;
176
+ _ . each ( bp . Measure . characteristics , function ( c ) {
177
+ tpa [ c ] = {
178
+ recent : undefined ,
179
+ history : [ ] ,
180
+ avg : { }
181
+ } ;
182
+ } ) ;
177
183
}
178
184
return tpa ;
179
185
} ;
@@ -188,8 +194,9 @@ bp.Report.rightSizeTimes = function(times) {
188
194
} ;
189
195
190
196
bp . Report . updateTimes = function ( tpa , index , reference , recentTime ) {
191
- tpa [ reference ] [ index ] = recentTime ;
192
- tpa [ reference ] = bp . Report . rightSizeTimes ( tpa [ reference ] ) ;
197
+ tpa [ reference ] . recent = recentTime ;
198
+ tpa [ reference ] . history [ index ] = recentTime ;
199
+ tpa [ reference ] . history = bp . Report . rightSizeTimes ( tpa [ reference ] . history ) ;
193
200
} ;
194
201
195
202
bp . Report . calcStats = function ( ) {
@@ -198,33 +205,21 @@ bp.Report.calcStats = function() {
198
205
var recentResult = bp . Runner . runState . recentResult [ bs . name ] ,
199
206
tpa = bp . Report . getTimesPerAction ( bs . name ) ;
200
207
201
- bp . Report . updateTimes ( tpa , tpa . nextEntry , 'gcTimes' , recentResult . gcTime ) ;
202
- bp . Report . updateTimes ( tpa , tpa . nextEntry , 'garbageCount' , recentResult . garbage / 1e3 ) ;
203
- bp . Report . updateTimes ( tpa , tpa . nextEntry , 'retainedCount' , recentResult . retainedMemory / 1e3 ) ;
204
- bp . Report . updateTimes ( tpa , tpa . nextEntry , 'testTimes' , recentResult . testTime ) ;
208
+ _ . each ( bp . Measure . characteristics , function ( c ) {
209
+ bp . Report . updateTimes ( tpa , tpa . nextEntry , c , recentResult [ c ] ) ;
210
+ var mean = bp . Statistics . getMean ( tpa [ c ] . history ) ;
211
+ var stdDev = bp . Statistics . calculateStandardDeviation ( tpa [ c ] . history , mean ) ;
212
+ tpa [ c ] . avg = {
213
+ mean : mean ,
214
+ stdDev : stdDev ,
215
+ coefficientOfVariation : bp . Statistics . calculateCoefficientOfVariation ( stdDev , mean )
216
+ } ;
217
+ } ) ;
205
218
206
219
tpa . nextEntry ++ ;
207
220
tpa . nextEntry %= bp . Runner . runState . numSamples ;
208
221
209
- var meanTestTime = bp . Statistics . getMean ( tpa . testTimes ) ;
210
- var testTimesStdDev = bp . Statistics . calculateStandardDeviation ( tpa . testTimes , meanTestTime ) ;
211
- var avgGCTime = bp . Statistics . getMean ( tpa . gcTimes ) ;
212
- var avg = {
213
- gcTime : avgGCTime ,
214
- testTime : meanTestTime ,
215
- combinedTime : meanTestTime + avgGCTime ,
216
- garbage : bp . Statistics . getMean ( tpa . garbageCount ) ,
217
- retained : bp . Statistics . getMean ( tpa . retainedCount ) ,
218
- testTimesStdDev : testTimesStdDev ,
219
- coefficientOfVariation : bp . Statistics . calculateCoefficientOfVariation ( testTimesStdDev , meanTestTime )
220
- } ;
221
-
222
- var reportModel = _ . clone ( tpa ) ;
223
- reportModel . name = bs . name ;
224
- reportModel . avg = avg ;
225
- reportModel . testTimes = tpa . testTimes ;
226
-
227
- report += bp . Report . generatePartial ( reportModel ) ;
222
+ report += bp . Report . generatePartial ( tpa ) ;
228
223
} ) ;
229
224
return report ;
230
225
} ;
0 commit comments