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

Side by Side Diff: tests/lib/async/slow_consumer2_test.dart

Issue 23522012: Replace ReceivePorts with asyncStart|End in some tests. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Remove bad comment. Created 7 years, 3 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 | « tests/lib/async/run_zoned8_test.dart ('k') | tests/lib/async/slow_consumer3_test.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 // VMOptions=--old_gen_heap_size=64 5 // VMOptions=--old_gen_heap_size=64
6 6
7 library slow_consumer2_test; 7 library slow_consumer2_test;
8 8
9 import 'package:async_helper/async_helper.dart';
9 import "package:expect/expect.dart"; 10 import "package:expect/expect.dart";
10 import 'dart:async'; 11 import 'dart:async';
11 import 'dart:isolate';
12 12
13 const int KB = 1024; 13 const int KB = 1024;
14 const int MB = KB * KB; 14 const int MB = KB * KB;
15 const int GB = KB * KB * KB; 15 const int GB = KB * KB * KB;
16 16
17 class SlowConsumer extends StreamConsumer { 17 class SlowConsumer extends StreamConsumer {
18 int receivedCount = 0; 18 int receivedCount = 0;
19 final int bytesPerSecond; 19 final int bytesPerSecond;
20 final int bufferSize; 20 final int bufferSize;
21 final List bufferedData = []; 21 final List bufferedData = [];
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
98 } 98 }
99 99
100 onPauseStateChange() { 100 onPauseStateChange() {
101 // We don't care if we just unpaused or paused. In either case we just 101 // We don't care if we just unpaused or paused. In either case we just
102 // call send which will test it for us. 102 // call send which will test it for us.
103 send(); 103 send();
104 } 104 }
105 } 105 }
106 106
107 main() { 107 main() {
108 var port = new ReceivePort(); 108 asyncStart();
109 // The data provider can deliver 800MB/s of data. It sends 100MB of data to 109 // The data provider can deliver 800MB/s of data. It sends 100MB of data to
110 // the slower consumer who can only read 200MB/s. The data is sent in 1MB 110 // the slower consumer who can only read 200MB/s. The data is sent in 1MB
111 // chunks. The consumer has a buffer of 5MB. That is, it can accept a few 111 // chunks. The consumer has a buffer of 5MB. That is, it can accept a few
112 // packages without pausing its input. 112 // packages without pausing its input.
113 // 113 //
114 // This test is limited to 32MB of heap-space (see VMOptions on top of the 114 // This test is limited to 32MB of heap-space (see VMOptions on top of the
115 // file). If the consumer doesn't pause the data-provider it will run out of 115 // file). If the consumer doesn't pause the data-provider it will run out of
116 // heap-space. 116 // heap-space.
117 117
118 new DataProvider(800 * MB, 100 * MB, 1 * MB).stream 118 new DataProvider(800 * MB, 100 * MB, 1 * MB).stream
119 .pipe(new SlowConsumer(200 * MB, 5 * MB)) 119 .pipe(new SlowConsumer(200 * MB, 5 * MB))
120 .then((count) { 120 .then((count) {
121 port.close();
122 Expect.equals(100 * MB, count); 121 Expect.equals(100 * MB, count);
122 asyncEnd();
123 }); 123 });
124 } 124 }
OLDNEW
« no previous file with comments | « tests/lib/async/run_zoned8_test.dart ('k') | tests/lib/async/slow_consumer3_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698