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

Side by Side Diff: runtime/vm/snapshot_test.dart

Issue 11770004: Rename Date to DateTime. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Address comments and keep Backwards-compatibility class Date. Created 7 years, 11 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 | « runtime/lib/math_patch.dart ('k') | samples/chat/chat_server_lib.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 // 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 6
7 class Fields { 7 class Fields {
8 Fields(int i, int j) : fld1 = i, fld2 = j, fld5 = true {} 8 Fields(int i, int j) : fld1 = i, fld2 = j, fld5 = true {}
9 int fld1; 9 int fld1;
10 final int fld2; 10 final int fld2;
(...skipping 724 matching lines...) Expand 10 before | Expand all | Expand 10 after
735 void setup() { } 735 void setup() { }
736 736
737 // Not measures teardown code executed after the benchark runs. 737 // Not measures teardown code executed after the benchark runs.
738 void teardown() { } 738 void teardown() { }
739 739
740 // Measures the score for this benchmark by executing it repeately until 740 // Measures the score for this benchmark by executing it repeately until
741 // time minimum has been reached. 741 // time minimum has been reached.
742 static double measureFor(Function f, int timeMinimum) { 742 static double measureFor(Function f, int timeMinimum) {
743 int time = 0; 743 int time = 0;
744 int iter = 0; 744 int iter = 0;
745 Date start = new Date.now(); 745 DateTime start = new DateTime.now();
746 while (time < timeMinimum) { 746 while (time < timeMinimum) {
747 f(); 747 f();
748 time = (new Date.now().difference(start)).inMilliseconds; 748 time = (new DateTime.now().difference(start)).inMilliseconds;
749 iter++; 749 iter++;
750 } 750 }
751 // Force double result by using a double constant. 751 // Force double result by using a double constant.
752 return (1000.0 * iter) / time; 752 return (1000.0 * iter) / time;
753 } 753 }
754 754
755 // Measures the score for the benchmark and returns it. 755 // Measures the score for the benchmark and returns it.
756 double measure() { 756 double measure() {
757 setup(); 757 setup();
758 // Warmup for at least 100ms. Discard result. 758 // Warmup for at least 100ms. Discard result.
(...skipping 346 matching lines...) Expand 10 before | Expand all | Expand 10 after
1105 SendPort _pong = spawnFunction(pong); 1105 SendPort _pong = spawnFunction(pong);
1106 play(); 1106 play();
1107 } 1107 }
1108 1108
1109 void startRound() { 1109 void startRound() {
1110 _iterations++; 1110 _iterations++;
1111 _pong.send(Benchmark1.INIT_MESSAGE, _pingPort); 1111 _pong.send(Benchmark1.INIT_MESSAGE, _pingPort);
1112 } 1112 }
1113 1113
1114 void evaluateRound() { 1114 void evaluateRound() {
1115 int time = (new Date.now().difference(_start)).inMilliseconds; 1115 int time = (new DateTime.now().difference(_start)).inMilliseconds;
1116 if (!_warmedup && time < Benchmark1.WARMUP_TIME) { 1116 if (!_warmedup && time < Benchmark1.WARMUP_TIME) {
1117 startRound(); 1117 startRound();
1118 } else if (!_warmedup) { 1118 } else if (!_warmedup) {
1119 _warmedup = true; 1119 _warmedup = true;
1120 _start = new Date.now(); 1120 _start = new DateTime.now();
1121 _iterations = 0; 1121 _iterations = 0;
1122 startRound(); 1122 startRound();
1123 } else if (_warmedup && time < Benchmark1.RUN_TIME) { 1123 } else if (_warmedup && time < Benchmark1.RUN_TIME) {
1124 startRound(); 1124 startRound();
1125 } else { 1125 } else {
1126 shutdown(); 1126 shutdown();
1127 Benchmark1.add_result((1.0 * _iterations * Benchmark1.MESSAGES) / time); 1127 Benchmark1.add_result((1.0 * _iterations * Benchmark1.MESSAGES) / time);
1128 if (Benchmark1.run() < Benchmark1.RUNS) { 1128 if (Benchmark1.run() < Benchmark1.RUNS) {
1129 new PingPongGame(); 1129 new PingPongGame();
1130 } else { 1130 } else {
1131 print("PingPong: ", Benchmark1.get_result()); 1131 print("PingPong: ", Benchmark1.get_result());
1132 } 1132 }
1133 } 1133 }
1134 } 1134 }
1135 1135
1136 void play() { 1136 void play() {
1137 _ping.receive((int message, SendPort replyTo) { 1137 _ping.receive((int message, SendPort replyTo) {
1138 if (message < Benchmark1.MESSAGES) { 1138 if (message < Benchmark1.MESSAGES) {
1139 _pong.send(++message, null); 1139 _pong.send(++message, null);
1140 } else { 1140 } else {
1141 evaluateRound(); 1141 evaluateRound();
1142 } 1142 }
1143 }); 1143 });
1144 _start = new Date.now(); 1144 _start = new DateTime.now();
1145 startRound(); 1145 startRound();
1146 } 1146 }
1147 1147
1148 void shutdown() { 1148 void shutdown() {
1149 _pong.send(Benchmark1.TERMINATION_MESSAGE, null); 1149 _pong.send(Benchmark1.TERMINATION_MESSAGE, null);
1150 _ping.close(); 1150 _ping.close();
1151 } 1151 }
1152 1152
1153 Date _start; 1153 DateTime _start;
1154 SendPort _pong; 1154 SendPort _pong;
1155 SendPort _pingPort; 1155 SendPort _pingPort;
1156 ReceivePort _ping; 1156 ReceivePort _ping;
1157 bool _warmedup; 1157 bool _warmedup;
1158 int _iterations; 1158 int _iterations;
1159 } 1159 }
1160 1160
1161 void pong() { 1161 void pong() {
1162 port.receive((message, SendPort replyTo) { 1162 port.receive((message, SendPort replyTo) {
1163 if (message == Benchmark1.INIT_MESSAGE) { 1163 if (message == Benchmark1.INIT_MESSAGE) {
(...skipping 385 matching lines...) Expand 10 before | Expand all | Expand 10 after
1549 void processLines() { 1549 void processLines() {
1550 port.receive((message, SendPort replyTo) { 1550 port.receive((message, SendPort replyTo) {
1551 if (message == TERMINATION_MESSAGE) { 1551 if (message == TERMINATION_MESSAGE) {
1552 assert(replyTo == null); 1552 assert(replyTo == null);
1553 port.close(); 1553 port.close();
1554 } else { 1554 } else {
1555 replyTo.send(processLine(message), null); 1555 replyTo.send(processLine(message), null);
1556 } 1556 }
1557 }); 1557 });
1558 } 1558 }
OLDNEW
« no previous file with comments | « runtime/lib/math_patch.dart ('k') | samples/chat/chat_server_lib.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698