OLD | NEW |
---|---|
1 // There are tests for computeStatistics() located in LayoutTests/fast/harness/p erftests | 1 // There are tests for computeStatistics() located in LayoutTests/fast/harness/p erftests |
2 | 2 |
3 if (window.testRunner) { | 3 if (window.testRunner) { |
4 testRunner.waitUntilDone(); | 4 testRunner.waitUntilDone(); |
5 testRunner.dumpAsText(); | 5 testRunner.dumpAsText(); |
6 } | 6 } |
7 | 7 |
8 (function () { | 8 (function () { |
9 var logLines = null; | 9 var logLines = null; |
10 var completedIterations = -1; | 10 var completedIterations = -1; |
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
138 } | 138 } |
139 | 139 |
140 PerfTestRunner.forceLayout = function(doc) { | 140 PerfTestRunner.forceLayout = function(doc) { |
141 doc = doc || document; | 141 doc = doc || document; |
142 if (doc.body) | 142 if (doc.body) |
143 doc.body.offsetHeight; | 143 doc.body.offsetHeight; |
144 else if (doc.documentElement) | 144 else if (doc.documentElement) |
145 doc.documentElement.offsetHeight; | 145 doc.documentElement.offsetHeight; |
146 }; | 146 }; |
147 | 147 |
148 function start(test, runner) { | 148 function start(test, scheduler, runner) { |
149 if (!test) { | 149 if (!test) { |
150 PerfTestRunner.logFatalError("Got a bad test object."); | 150 PerfTestRunner.logFatalError("Got a bad test object."); |
151 return; | 151 return; |
152 } | 152 } |
153 currentTest = test; | 153 currentTest = test; |
154 // FIXME: We should be using multiple instances of test runner on Dromae o as well but it's too slow now. | 154 // FIXME: We should be using multiple instances of test runner on Dromae o as well but it's too slow now. |
155 // FIXME: Don't hard code the number of in-process iterations to use ins ide a test runner. | 155 // FIXME: Don't hard code the number of in-process iterations to use ins ide a test runner. |
156 iterationCount = test.dromaeoIterationCount || (window.testRunner ? 5 : 20); | 156 iterationCount = test.dromaeoIterationCount || (window.testRunner ? 5 : 20); |
157 if (test.warmUpCount && test.warmUpCount > 0) | 157 if (test.warmUpCount && test.warmUpCount > 0) |
158 completedIterations = -test.warmUpCount; | 158 completedIterations = -test.warmUpCount; |
159 logLines = window.testRunner ? [] : null; | 159 logLines = window.testRunner ? [] : null; |
160 PerfTestRunner.log("Running " + iterationCount + " times"); | 160 PerfTestRunner.log("Running " + iterationCount + " times"); |
161 if (test.doNotIgnoreInitialRun) | 161 if (test.doNotIgnoreInitialRun) |
162 completedIterations++; | 162 completedIterations++; |
163 if (runner) | 163 if (runner) |
164 scheduleNextRun(runner); | 164 scheduleNextRun(scheduler, runner); |
165 } | 165 } |
166 | 166 |
167 function scheduleNextRun(runner) { | 167 function scheduleNextRun(scheduler, runner) { |
168 PerfTestRunner.gc(); | 168 PerfTestRunner.gc(); |
169 window.setTimeout(function () { | 169 scheduler(function () { |
170 try { | 170 try { |
171 if (currentTest.setup) | 171 if (currentTest.setup) |
172 currentTest.setup(); | 172 currentTest.setup(); |
173 | 173 |
174 var measuredValue = runner(); | 174 var measuredValue = runner(); |
175 } catch (exception) { | 175 } catch (exception) { |
176 PerfTestRunner.logFatalError("Got an exception while running tes t.run with name=" + exception.name + ", message=" + exception.message); | 176 PerfTestRunner.logFatalError("Got an exception while running tes t.run with name=" + exception.name + ", message=" + exception.message); |
177 return; | 177 return; |
178 } | 178 } |
179 | 179 |
180 completedIterations++; | 180 completedIterations++; |
181 | 181 |
182 try { | 182 try { |
183 ignoreWarmUpAndLog(measuredValue); | 183 ignoreWarmUpAndLog(measuredValue); |
184 } catch (exception) { | 184 } catch (exception) { |
185 PerfTestRunner.logFatalError("Got an exception while logging the result with name=" + exception.name + ", message=" + exception.message); | 185 PerfTestRunner.logFatalError("Got an exception while logging the result with name=" + exception.name + ", message=" + exception.message); |
186 return; | 186 return; |
187 } | 187 } |
188 | 188 |
189 if (completedIterations < iterationCount) | 189 if (completedIterations < iterationCount) |
190 scheduleNextRun(runner); | 190 scheduleNextRun(scheduler, runner); |
191 else | 191 else |
192 finish(); | 192 finish(); |
193 }, 0); | 193 }); |
194 } | 194 } |
195 | 195 |
196 function ignoreWarmUpAndLog(measuredValue) { | 196 function ignoreWarmUpAndLog(measuredValue) { |
197 var labeledResult = measuredValue + " " + PerfTestRunner.unit; | 197 var labeledResult = measuredValue + " " + PerfTestRunner.unit; |
198 if (completedIterations <= 0) | 198 if (completedIterations <= 0) |
199 PerfTestRunner.log("Ignoring warm-up run (" + labeledResult + ")"); | 199 PerfTestRunner.log("Ignoring warm-up run (" + labeledResult + ")"); |
200 else { | 200 else { |
201 results.push(measuredValue); | 201 results.push(measuredValue); |
202 if (window.internals && !currentTest.doNotMeasureMemoryUsage) { | 202 if (window.internals && !currentTest.doNotMeasureMemoryUsage) { |
203 jsHeapResults.push(getUsedJSHeap()); | 203 jsHeapResults.push(getUsedJSHeap()); |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
238 ignoreWarmUpAndLog(measuredValue); | 238 ignoreWarmUpAndLog(measuredValue); |
239 } catch (exception) { | 239 } catch (exception) { |
240 PerfTestRunner.logFatalError("Got an exception while logging the res ult with name=" + exception.name + ", message=" + exception.message); | 240 PerfTestRunner.logFatalError("Got an exception while logging the res ult with name=" + exception.name + ", message=" + exception.message); |
241 return; | 241 return; |
242 } | 242 } |
243 | 243 |
244 if (completedIterations >= iterationCount) | 244 if (completedIterations >= iterationCount) |
245 finish(); | 245 finish(); |
246 } | 246 } |
247 | 247 |
248 PerfTestRunner.measureFrameTime = function (test) { | |
249 PerfTestRunner.unit = "ms"; | |
250 start(test, requestAnimationFrame, measureFrameTimeOnce); | |
251 } | |
252 | |
253 var lastFrameTime = -1; | |
254 function measureFrameTimeOnce() { | |
255 var now = PerfTestRunner.now(); | |
256 var result = lastFrameTime == -1 ? 0 : now - lastFrameTime; | |
257 lastFrameTime = now; | |
258 | |
259 var returnValue = currentTest.run(); | |
260 if (returnValue - 0 === returnValue) { | |
261 if (returnValue < 0) | |
262 PerfTestRunner.log("runFunction returned a negative value: " + r eturnValue); | |
263 return returnValue; | |
264 } | |
265 | |
266 return result; | |
267 } | |
268 | |
248 PerfTestRunner.measureTime = function (test) { | 269 PerfTestRunner.measureTime = function (test) { |
249 PerfTestRunner.unit = "ms"; | 270 PerfTestRunner.unit = "ms"; |
250 start(test, measureTimeOnce); | 271 start(test, zeroTimeoutScheduler, measureTimeOnce); |
272 } | |
273 | |
274 function zeroTimeoutScheduler(task) { | |
275 setTimneout(task, 0); | |
pdr.
2016/10/18 23:22:08
setTimeout?
Xianzhu
2016/10/19 03:38:15
Fixed.
It did break harness tests. Added new harn
| |
251 } | 276 } |
252 | 277 |
253 function measureTimeOnce() { | 278 function measureTimeOnce() { |
254 var start = PerfTestRunner.now(); | 279 var start = PerfTestRunner.now(); |
255 var returnValue = currentTest.run(); | 280 var returnValue = currentTest.run(); |
256 var end = PerfTestRunner.now(); | 281 var end = PerfTestRunner.now(); |
257 | 282 |
258 if (returnValue - 0 === returnValue) { | 283 if (returnValue - 0 === returnValue) { |
259 if (returnValue < 0) | 284 if (returnValue < 0) |
260 PerfTestRunner.log("runFunction returned a negative value: " + r eturnValue); | 285 PerfTestRunner.log("runFunction returned a negative value: " + r eturnValue); |
261 return returnValue; | 286 return returnValue; |
262 } | 287 } |
263 | 288 |
264 return end - start; | 289 return end - start; |
265 } | 290 } |
266 | 291 |
267 PerfTestRunner.measureRunsPerSecond = function (test) { | 292 PerfTestRunner.measureRunsPerSecond = function (test) { |
268 PerfTestRunner.unit = "runs/s"; | 293 PerfTestRunner.unit = "runs/s"; |
269 start(test, measureRunsPerSecondOnce); | 294 start(test, zeroTimeoutScheduler, measureRunsPerSecondOnce); |
270 } | 295 } |
271 | 296 |
272 function measureRunsPerSecondOnce() { | 297 function measureRunsPerSecondOnce() { |
273 var timeToRun = 750; | 298 var timeToRun = 750; |
274 var totalTime = 0; | 299 var totalTime = 0; |
275 var numberOfRuns = 0; | 300 var numberOfRuns = 0; |
276 | 301 |
277 while (totalTime < timeToRun) { | 302 while (totalTime < timeToRun) { |
278 totalTime += callRunAndMeasureTime(callsPerIteration); | 303 totalTime += callRunAndMeasureTime(callsPerIteration); |
279 numberOfRuns += callsPerIteration; | 304 numberOfRuns += callsPerIteration; |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
326 | 351 |
327 iframe.contentDocument.close(); | 352 iframe.contentDocument.close(); |
328 document.body.removeChild(iframe); | 353 document.body.removeChild(iframe); |
329 }; | 354 }; |
330 | 355 |
331 PerfTestRunner.measureTime(test); | 356 PerfTestRunner.measureTime(test); |
332 } | 357 } |
333 | 358 |
334 window.PerfTestRunner = PerfTestRunner; | 359 window.PerfTestRunner = PerfTestRunner; |
335 })(); | 360 })(); |
OLD | NEW |