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

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

Issue 11194037: Fix Ping Pong snapshot test (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 8 years, 2 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 | « no previous file | no next file » | 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 1068 matching lines...) Expand 10 before | Expand all | Expand 10 after
1079 return _opsms / _run; 1079 return _opsms / _run;
1080 } 1080 }
1081 1081
1082 static void init() { 1082 static void init() {
1083 _run = 0; 1083 _run = 0;
1084 _opsms = 0.0; 1084 _opsms = 0.0;
1085 } 1085 }
1086 1086
1087 static void main() { 1087 static void main() {
1088 init(); 1088 init();
1089 PingPongGame pingPongGame = new PingPongGame.play(); 1089 PingPongGame pingPongGame = new PingPongGame();
1090 } 1090 }
1091 1091
1092 static var _run; 1092 static var _run;
1093 static var _opsms; 1093 static var _opsms;
1094 } 1094 }
1095 1095
1096 class PingPongGame { 1096 class PingPongGame {
1097 1097
1098 PingPongGame.play() 1098 PingPongGame()
1099 : _ping = new ReceivePort(), 1099 : _ping = new ReceivePort(),
1100 _pingPort = _ping.toSendPort(), 1100 _pingPort = _ping.toSendPort(),
1101 _pong = null, 1101 _pong = null,
1102 _warmedup = false, 1102 _warmedup = false,
1103 _iterations = 0 { 1103 _iterations = 0 {
1104 SendPort _pong = spawnFunction(pong); 1104 SendPort _pong = spawnFunction(pong);
1105 play(); 1105 play();
1106 } 1106 }
1107 1107
1108 void startRound() { 1108 void startRound() {
1109 _iterations++; 1109 _iterations++;
1110 _pong.send(Benchmark1.INIT_MESSAGE, _pingPort); 1110 _pong.send(Benchmark1.INIT_MESSAGE, _pingPort);
1111 } 1111 }
1112 1112
1113 void evaluateRound() { 1113 void evaluateRound() {
1114 int time = (new Date.now().difference(_start)).inMilliseconds; 1114 int time = (new Date.now().difference(_start)).inMilliseconds;
1115 if (!_warmedup && time < Benchmark1.WARMUP_TIME) { 1115 if (!_warmedup && time < Benchmark1.WARMUP_TIME) {
1116 startRound(); 1116 startRound();
1117 } else if (!_warmedup) { 1117 } else if (!_warmedup) {
1118 _warmedup = true; 1118 _warmedup = true;
1119 _start = new Date.now(); 1119 _start = new Date.now();
1120 _iterations = 0; 1120 _iterations = 0;
1121 startRound(); 1121 startRound();
1122 } else if (_warmedup && time < Benchmark1.RUN_TIME) { 1122 } else if (_warmedup && time < Benchmark1.RUN_TIME) {
1123 startRound(); 1123 startRound();
1124 } else { 1124 } else {
1125 shutdown(); 1125 shutdown();
1126 Benchmark1.add_result((1.0 * _iterations * Benchmark1.MESSAGES) / time); 1126 Benchmark1.add_result((1.0 * _iterations * Benchmark1.MESSAGES) / time);
1127 if (Benchmark1.run() < Benchmark1.RUNS) { 1127 if (Benchmark1.run() < Benchmark1.RUNS) {
1128 new PingPongGame.play(); 1128 new PingPongGame();
1129 } else { 1129 } else {
1130 print("PingPong: ", Benchmark1.get_result()); 1130 print("PingPong: ", Benchmark1.get_result());
1131 } 1131 }
1132 } 1132 }
1133 } 1133 }
1134 1134
1135 void play() { 1135 void play() {
1136 _ping.receive((int message, SendPort replyTo) { 1136 _ping.receive((int message, SendPort replyTo) {
1137 if (message < Benchmark1.MESSAGES) { 1137 if (message < Benchmark1.MESSAGES) {
1138 _pong.send(++message, null); 1138 _pong.send(++message, null);
(...skipping 409 matching lines...) Expand 10 before | Expand all | Expand 10 after
1548 void processLines() { 1548 void processLines() {
1549 port.receive((message, SendPort replyTo) { 1549 port.receive((message, SendPort replyTo) {
1550 if (message == TERMINATION_MESSAGE) { 1550 if (message == TERMINATION_MESSAGE) {
1551 assert(replyTo == null); 1551 assert(replyTo == null);
1552 port.close(); 1552 port.close();
1553 } else { 1553 } else {
1554 replyTo.send(processLine(message), null); 1554 replyTo.send(processLine(message), null);
1555 } 1555 }
1556 }); 1556 });
1557 } 1557 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698