Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(722)

Side by Side Diff: samples/third_party/dromaeo/tests/RunnerSuite.dart

Issue 12253011: Reapply remove setInterval. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « samples/third_party/dromaeo/Dromaeo.dart ('k') | sdk/lib/html/dart2js/html_dart2js.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
44 */ 44 */
45 Suite test(String name, Test test_) { 45 Suite test(String name, Test test_) {
46 _nTests++; 46 _nTests++;
47 // Don't execute the test immediately. 47 // Don't execute the test immediately.
48 return _addOperation(() { 48 return _addOperation(() {
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 timer 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 DateTime.now().millisecondsSinceEpoch; 59 final int start = new DateTime.now().millisecondsSinceEpoch;
60 60
61 int cur = new DateTime.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 DateTime.now().millisecondsSinceEpoch; 64 cur = new DateTime.now().millisecondsSinceEpoch;
(...skipping 18 matching lines...) Expand all
83 _postMessage('inited', { 'nTests': _nTests }); 83 _postMessage('inited', { 'nTests': _nTests });
84 84
85 } 85 }
86 86
87 _run() { 87 _run() {
88 int currentOperation = 0; 88 int currentOperation = 0;
89 handler() { 89 handler() {
90 if (currentOperation < _operations.length) { 90 if (currentOperation < _operations.length) {
91 _operations[currentOperation](); 91 _operations[currentOperation]();
92 currentOperation++; 92 currentOperation++;
93 _window.setTimeout(handler, 1); 93 new Timer(const Duration(milliseconds: 1), handler);
94 } else { 94 } else {
95 _postMessage('over'); 95 _postMessage('over');
96 } 96 }
97 } 97 }
98 _window.setTimeout(handler, 0); 98 Timer.run(handler);
99 } 99 }
100 100
101 _reportTestResults(String name, Result result) { 101 _reportTestResults(String name, Result result) {
102 _nRanTests++; 102 _nRanTests++;
103 _postMessage('result', { 103 _postMessage('result', {
104 'testName': name, 104 'testName': name,
105 'mean': result.mean, 105 'mean': result.mean,
106 'error': result.error, 106 'error': result.error,
107 'percent': (100.0 * _nRanTests / _nTests) 107 'percent': (100.0 * _nRanTests / _nTests)
108 }); 108 });
(...skipping 14 matching lines...) Expand all
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 }
OLDNEW
« no previous file with comments | « samples/third_party/dromaeo/Dromaeo.dart ('k') | sdk/lib/html/dart2js/html_dart2js.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698