OLD | NEW |
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, 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 import 'dart:isolate'; | 5 import 'dart:isolate'; |
6 import 'dart:async'; | 6 import 'dart:async'; |
7 | 7 |
8 class Expect { | 8 class Expect { |
9 static void equals(x, y) { | 9 static void equals(x, y) { |
10 if (x != y) throw new ArgumentError('not equal'); | 10 if (x != y) throw new ArgumentError('not equal'); |
(...skipping 713 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
724 // Exercices the benchmark. By default invokes [run] 10 times. | 724 // Exercices the benchmark. By default invokes [run] 10 times. |
725 void exercise() { | 725 void exercise() { |
726 for (int i = 0; i < 10; i++) { | 726 for (int i = 0; i < 10; i++) { |
727 run(); | 727 run(); |
728 } | 728 } |
729 } | 729 } |
730 | 730 |
731 // Not measured setup code executed prior to the benchmark runs. | 731 // Not measured setup code executed prior to the benchmark runs. |
732 void setup() {} | 732 void setup() {} |
733 | 733 |
734 // Not measures teardown code executed after the benchark runs. | 734 // Not measures teardown code executed after the benchmark runs. |
735 void teardown() {} | 735 void teardown() {} |
736 | 736 |
737 // Measures the score for this benchmark by executing it repeately until | 737 // Measures the score for this benchmark by executing it repeately until |
738 // time minimum has been reached. | 738 // time minimum has been reached. |
739 static double measureFor(Function f, int timeMinimum) { | 739 static double measureFor(Function f, int timeMinimum) { |
740 int time = 0; | 740 int time = 0; |
741 int iter = 0; | 741 int iter = 0; |
742 DateTime start = new DateTime.now(); | 742 DateTime start = new DateTime.now(); |
743 while (time < timeMinimum) { | 743 while (time < timeMinimum) { |
744 f(); | 744 f(); |
(...skipping 797 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1542 void processLines() { | 1542 void processLines() { |
1543 port.receive((message, SendPort replyTo) { | 1543 port.receive((message, SendPort replyTo) { |
1544 if (message == TERMINATION_MESSAGE) { | 1544 if (message == TERMINATION_MESSAGE) { |
1545 assert(replyTo == null); | 1545 assert(replyTo == null); |
1546 port.close(); | 1546 port.close(); |
1547 } else { | 1547 } else { |
1548 replyTo.send(processLine(message), null); | 1548 replyTo.send(processLine(message), null); |
1549 } | 1549 } |
1550 }); | 1550 }); |
1551 } | 1551 } |
OLD | NEW |