| OLD | NEW |
| 1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
| 3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
| 4 | 4 |
| 5 library test.timing; | 5 library test.timing; |
| 6 | 6 |
| 7 import 'dart:async'; | 7 import 'dart:async'; |
| 8 import 'dart:io'; | 8 import 'dart:io'; |
| 9 import 'dart:math'; | 9 import 'dart:math'; |
| 10 | 10 |
| (...skipping 206 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 217 * Perform any operations that part of a single iteration. It is the execution | 217 * Perform any operations that part of a single iteration. It is the execution |
| 218 * of this method that will be measured. | 218 * of this method that will be measured. |
| 219 */ | 219 */ |
| 220 Future perform(); | 220 Future perform(); |
| 221 | 221 |
| 222 /** | 222 /** |
| 223 * Return a future that will complete with a timing result representing the | 223 * Return a future that will complete with a timing result representing the |
| 224 * number of milliseconds required to perform the operation the specified | 224 * number of milliseconds required to perform the operation the specified |
| 225 * number of times. | 225 * number of times. |
| 226 */ | 226 */ |
| 227 Future<TimingResult> run() { | 227 Future<TimingResult> run() async { |
| 228 List<int> times = new List<int>(); | 228 List<int> times = new List<int>(); |
| 229 return oneTimeSetUp().then((_) { | 229 await oneTimeSetUp(); |
| 230 return _repeat(warmupCount, null).then((_) { | 230 await _repeat(warmupCount, null); |
| 231 return _repeat(timingCount, times).then((_) { | 231 await _repeat(timingCount, times); |
| 232 return oneTimeTearDown().then((_) { | 232 await oneTimeTearDown(); |
| 233 return new Future.value(new TimingResult(times)); | 233 return new Future<TimingResult>.value(new TimingResult(times)); |
| 234 }); | |
| 235 }); | |
| 236 }); | |
| 237 }); | |
| 238 } | 234 } |
| 239 | 235 |
| 240 /** | 236 /** |
| 241 * Perform any operations that need to be performed before each iteration. | 237 * Perform any operations that need to be performed before each iteration. |
| 242 */ | 238 */ |
| 243 Future setUp(); | 239 Future setUp(); |
| 244 | 240 |
| 245 /** | 241 /** |
| 246 * Convert the given [relativePath] to an absolute path, by interpreting it | 242 * Convert the given [relativePath] to an absolute path, by interpreting it |
| 247 * relative to [sourceDirectory]. On Windows any forward slashes in | 243 * relative to [sourceDirectory]. On Windows any forward slashes in |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 309 return new Future.value(); | 305 return new Future.value(); |
| 310 } | 306 } |
| 311 // Give the server a short time to comply with the shutdown request; if it | 307 // Give the server a short time to comply with the shutdown request; if it |
| 312 // doesn't exit, then forcibly terminate it. | 308 // doesn't exit, then forcibly terminate it. |
| 313 sendServerShutdown(); | 309 sendServerShutdown(); |
| 314 return server.exitCode.timeout(SHUTDOWN_TIMEOUT, onTimeout: () { | 310 return server.exitCode.timeout(SHUTDOWN_TIMEOUT, onTimeout: () { |
| 315 return server.kill('server failed to exit'); | 311 return server.kill('server failed to exit'); |
| 316 }); | 312 }); |
| 317 } | 313 } |
| 318 } | 314 } |
| OLD | NEW |