1
- BenchmarkRunnerState = Utilities . createClass (
2
- function ( suites )
1
+ /*
2
+ * Copyright (C) 2015-2020 Apple Inc. All rights reserved.
3
+ *
4
+ * Redistribution and use in source and binary forms, with or without
5
+ * modification, are permitted provided that the following conditions
6
+ * are met:
7
+ * 1. Redistributions of source code must retain the above copyright
8
+ * notice, this list of conditions and the following disclaimer.
9
+ * 2. Redistributions in binary form must reproduce the above copyright
10
+ * notice, this list of conditions and the following disclaimer in the
11
+ * documentation and/or other materials provided with the distribution.
12
+ *
13
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
14
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
15
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
16
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
17
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
18
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
19
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
20
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
21
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
22
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
23
+ * THE POSSIBILITY OF SUCH DAMAGE.
24
+ */
25
+
26
+ class BenchmarkRunnerState {
27
+ constructor ( suites )
3
28
{
4
29
this . _suites = suites ;
5
30
this . _suiteIndex = - 1 ;
6
31
this . _testIndex = 0 ;
7
32
this . next ( ) ;
8
- } , {
33
+ }
9
34
10
- currentSuite : function ( )
35
+ currentSuite ( )
11
36
{
12
37
return this . _suites [ this . _suiteIndex ] ;
13
- } ,
38
+ }
14
39
15
- currentTest : function ( )
40
+ currentTest ( )
16
41
{
17
42
var suite = this . currentSuite ( ) ;
18
43
return suite ? suite . tests [ this . _testIndex ] : null ;
19
- } ,
44
+ }
20
45
21
- isFirstTest : function ( )
46
+ isFirstTest ( )
22
47
{
23
48
return ! this . _testIndex ;
24
- } ,
49
+ }
25
50
26
- next : function ( )
51
+ next ( )
27
52
{
28
53
this . _testIndex ++ ;
29
54
@@ -35,9 +60,9 @@ BenchmarkRunnerState = Utilities.createClass(
35
60
do {
36
61
this . _suiteIndex ++ ;
37
62
} while ( this . _suiteIndex < this . _suites . length && this . _suites [ this . _suiteIndex ] . disabled ) ;
38
- } ,
63
+ }
39
64
40
- prepareCurrentTest : function ( runner , frame )
65
+ prepareCurrentTest ( runner , frame )
41
66
{
42
67
var test = this . currentTest ( ) ;
43
68
var promise = new SimplePromise ;
@@ -49,35 +74,35 @@ BenchmarkRunnerState = Utilities.createClass(
49
74
frame . src = "tests/" + test . url ;
50
75
return promise ;
51
76
}
52
- } ) ;
77
+ }
53
78
54
- BenchmarkRunner = Utilities . createClass (
55
- function ( suites , frameContainer , client )
79
+ class BenchmarkRunner {
80
+ constructor ( suites , frameContainer , client )
56
81
{
57
82
this . _suites = suites ;
58
83
this . _client = client ;
59
84
this . _frameContainer = frameContainer ;
60
- } , {
85
+ }
61
86
62
- _appendFrame : function ( )
87
+ _appendFrame ( )
63
88
{
64
89
var frame = document . createElement ( "iframe" ) ;
65
90
frame . setAttribute ( "scrolling" , "no" ) ;
66
91
67
92
this . _frameContainer . insertBefore ( frame , this . _frameContainer . firstChild ) ;
68
93
this . _frame = frame ;
69
94
return frame ;
70
- } ,
95
+ }
71
96
72
- _removeFrame : function ( )
97
+ _removeFrame ( )
73
98
{
74
99
if ( this . _frame ) {
75
100
this . _frame . parentNode . removeChild ( this . _frame ) ;
76
101
this . _frame = null ;
77
102
}
78
- } ,
103
+ }
79
104
80
- _runBenchmarkAndRecordResults : function ( state )
105
+ _runBenchmarkAndRecordResults ( state )
81
106
{
82
107
var promise = new SimplePromise ;
83
108
var suite = state . currentSuite ( ) ;
@@ -110,9 +135,9 @@ BenchmarkRunner = Utilities.createClass(
110
135
} ) ;
111
136
112
137
return promise ;
113
- } ,
138
+ }
114
139
115
- step : function ( state )
140
+ step ( state )
116
141
{
117
142
if ( ! state ) {
118
143
state = new BenchmarkRunnerState ( this . _suites ) ;
@@ -134,18 +159,18 @@ BenchmarkRunner = Utilities.createClass(
134
159
return state . prepareCurrentTest ( this , this . _frame ) . then ( function ( prepareReturnValue ) {
135
160
return this . _runBenchmarkAndRecordResults ( state ) ;
136
161
} . bind ( this ) ) ;
137
- } ,
162
+ }
138
163
139
- runAllSteps : function ( startingState )
164
+ runAllSteps ( startingState )
140
165
{
141
166
var nextCallee = this . runAllSteps . bind ( this ) ;
142
167
this . step ( startingState ) . then ( function ( nextState ) {
143
168
if ( nextState )
144
169
nextCallee ( nextState ) ;
145
170
} ) ;
146
- } ,
171
+ }
147
172
148
- runMultipleIterations : function ( )
173
+ runMultipleIterations ( )
149
174
{
150
175
var self = this ;
151
176
var currentIteration = 0 ;
@@ -164,9 +189,9 @@ BenchmarkRunner = Utilities.createClass(
164
189
this . _client . willStartFirstIteration ( ) ;
165
190
166
191
this . runAllSteps ( ) ;
167
- } ,
192
+ }
168
193
169
- _finalize : function ( )
194
+ _finalize ( )
170
195
{
171
196
this . _removeFrame ( ) ;
172
197
@@ -176,4 +201,4 @@ BenchmarkRunner = Utilities.createClass(
176
201
if ( this . _runNextIteration )
177
202
this . _runNextIteration ( ) ;
178
203
}
179
- } ) ;
204
+ }
0 commit comments