| OLD | NEW |
| 1 typedef void Test(); | 1 typedef void Test(); |
| 2 typedef void Operation(); | 2 typedef void Operation(); |
| 3 typedef void Reporter(Map<String, Result> results); | 3 typedef void Reporter(Map<String, Result> results); |
| 4 | 4 |
| 5 class Suite { | 5 class Suite { |
| 6 /** | 6 /** |
| 7 * Ctor. | 7 * Ctor. |
| 8 * [:_window:] The window of the suite. | 8 * [:_window:] The window of the suite. |
| 9 * [:_name:] The name of the suite. | 9 * [:_name:] The name of the suite. |
| 10 */ | 10 */ |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 53 // List of number of runs in seconds. | 53 // List of number of runs in seconds. |
| 54 List<double> runsPerSecond = new List<double>(); | 54 List<double> runsPerSecond = new List<double>(); |
| 55 | 55 |
| 56 // Run the test several times. | 56 // Run the test several times. |
| 57 try { | 57 try { |
| 58 // TODO(antonm): use .setTimeout to schedule next run as JS | 58 // TODO(antonm): use .setTimeout to schedule next run as JS |
| 59 // version does. That allows to report the intermidiate results | 59 // version does. That allows to report the intermidiate results |
| 60 // more smoothly as well. | 60 // more smoothly as well. |
| 61 for (int i = 0; i < _N_RUNS; i++) { | 61 for (int i = 0; i < _N_RUNS; i++) { |
| 62 int runs = 0; | 62 int runs = 0; |
| 63 final int start = new Date.now().value; | 63 final int start = new Date.now().millisecondsSinceEpoch; |
| 64 | 64 |
| 65 int cur = new Date.now().value; | 65 int cur = new Date.now().millisecondsSinceEpoch; |
| 66 while ((cur - start) < 1000) { | 66 while ((cur - start) < 1000) { |
| 67 test_(); | 67 test_(); |
| 68 cur = new Date.now().value; | 68 cur = new Date.now().millisecondsSinceEpoch; |
| 69 runs++; | 69 runs++; |
| 70 } | 70 } |
| 71 | 71 |
| 72 runsPerSecond.add((runs * 1000.0) / (cur - start)); | 72 runsPerSecond.add((runs * 1000.0) / (cur - start)); |
| 73 } | 73 } |
| 74 } catch(var exception, var stacktrace) { | 74 } catch(var exception, var stacktrace) { |
| 75 _window.alert('Exception ${exception}: ${stacktrace}'); | 75 _window.alert('Exception ${exception}: ${stacktrace}'); |
| 76 return; | 76 return; |
| 77 } | 77 } |
| 78 _reportTestResults(name, new Result(runsPerSecond)); | 78 _reportTestResults(name, new Result(runsPerSecond)); |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 127 | 127 |
| 128 List<Operation> _operations; | 128 List<Operation> _operations; |
| 129 int _nTests; | 129 int _nTests; |
| 130 int _nRanTests; | 130 int _nRanTests; |
| 131 | 131 |
| 132 Suite _addOperation(Operation operation) { | 132 Suite _addOperation(Operation operation) { |
| 133 _operations.add(operation); | 133 _operations.add(operation); |
| 134 return this; | 134 return this; |
| 135 } | 135 } |
| 136 } | 136 } |
| OLD | NEW |