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