23
23
* THE POSSIBILITY OF SUCH DAMAGE.
24
24
*/
25
25
26
+ class RunData {
27
+ constructor ( version , options , runs = [ ] )
28
+ {
29
+ this . version = version ;
30
+ this . options = options ;
31
+ this . runs = runs ;
32
+ }
33
+ }
34
+
26
35
class ScoreCalculator {
27
- constructor ( version , options , testData )
36
+ constructor ( runData )
28
37
{
29
- this . _iterationsSamplers = [ ] ;
30
- this . _options = options ;
38
+ this . _runData = runData ;
31
39
this . _results = null ;
32
- this . _version = version ;
33
- this . _targetFrameRate = options [ "frame-rate" ] ;
34
- this . _systemFrameRate = options [ "system-frame-rate" ] ;
40
+ this . _targetFrameRate = runData . options [ "frame-rate" ] ;
41
+ this . _systemFrameRate = runData . options [ "system-frame-rate" ] ;
35
42
36
43
const defaultBootstrapIterations = 2500 ;
37
- if ( ! Object . hasOwn ( this . _options , Strings . json . bootstrapIterations ) )
38
- this . _options [ Strings . json . bootstrapIterations ] = defaultBootstrapIterations ;
44
+ if ( ! Object . hasOwn ( this . _runData . options , Strings . json . bootstrapIterations ) )
45
+ this . _runData . options [ Strings . json . bootstrapIterations ] = defaultBootstrapIterations ;
39
46
40
- if ( testData ) {
41
- this . _iterationsSamplers = testData ;
47
+ if ( this . _runData . runs . length > 0 )
42
48
this . _processData ( ) ;
43
- }
44
49
}
45
50
46
51
get targetFrameRate ( )
@@ -50,7 +55,7 @@ class ScoreCalculator {
50
55
51
56
push ( suitesSamplers )
52
57
{
53
- this . _iterationsSamplers . push ( suitesSamplers ) ;
58
+ this . _runData . runs . push ( suitesSamplers ) ;
54
59
}
55
60
56
61
_processData ( )
@@ -59,7 +64,7 @@ class ScoreCalculator {
59
64
this . _results [ Strings . json . results . iterations ] = [ ] ;
60
65
61
66
var iterationsScores = [ ] ;
62
- this . _iterationsSamplers . forEach ( function ( iteration , index ) {
67
+ this . _runData . runs . forEach ( function ( iteration , index ) {
63
68
var testsScores = [ ] ;
64
69
var testsLowerBoundScores = [ ] ;
65
70
var testsUpperBoundScores = [ ] ;
@@ -95,7 +100,7 @@ class ScoreCalculator {
95
100
iterationsScores . push ( result [ Strings . json . score ] ) ;
96
101
} , this ) ;
97
102
98
- this . _results [ Strings . json . version ] = this . _version ;
103
+ this . _results [ Strings . json . version ] = this . _runData . version ;
99
104
this . _results [ Strings . json . fps ] = this . _targetFrameRate ;
100
105
this . _results [ Strings . json . score ] = Statistics . sampleMean ( iterationsScores . length , iterationsScores . reduce ( function ( a , b ) { return a + b ; } ) ) ;
101
106
this . _results [ Strings . json . scoreLowerBound ] = this . _results [ Strings . json . results . iterations ] [ 0 ] [ Strings . json . scoreLowerBound ] ;
@@ -149,7 +154,7 @@ class ScoreCalculator {
149
154
samples [ seriesName ] = new SampleData ( series . fieldMap , series . data ) ;
150
155
} ) ;
151
156
152
- var isRampController = this . _options [ " controller" ] == "ramp" ;
157
+ var isRampController = this . _runData . options [ Strings . json . controller ] == "ramp" ;
153
158
var predominantProfile = "" ;
154
159
if ( isRampController ) {
155
160
var profiles = { } ;
@@ -198,7 +203,7 @@ class ScoreCalculator {
198
203
experimentResult [ Strings . json . measurements . stdev ] = timeComplexity . standardDeviation ( ) ;
199
204
experimentResult [ Strings . json . measurements . percent ] = timeComplexity . percentage ( ) ;
200
205
201
- const bootstrapIterations = this . _options [ Strings . json . bootstrapIterations ] ;
206
+ const bootstrapIterations = this . _runData . options [ Strings . json . bootstrapIterations ] ;
202
207
var bootstrapResult = Regression . bootstrap ( regressionResult . samples . data , bootstrapIterations , function ( resampleData ) {
203
208
var complexityIndex = regressionResult . samples . fieldMap [ Strings . json . complexity ] ;
204
209
resampleData . sort ( function ( a , b ) {
@@ -265,7 +270,7 @@ class ScoreCalculator {
265
270
266
271
get data ( )
267
272
{
268
- return this . _iterationsSamplers ;
273
+ return this . _runData . runs ;
269
274
}
270
275
271
276
get results ( )
@@ -278,12 +283,12 @@ class ScoreCalculator {
278
283
279
284
get options ( )
280
285
{
281
- return this . _options ;
286
+ return this . _runData . options ;
282
287
}
283
288
284
289
get version ( )
285
290
{
286
- return this . _version ;
291
+ return this . _runData . version ;
287
292
}
288
293
289
294
_getResultsProperty ( property )
0 commit comments