| 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 // 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:expect/expect.dart"; | |
| 10 import 'dart:async'; | 9 import 'dart:async'; |
| 11 import 'dart:isolate'; | 10 import 'dart:isolate'; |
| 12 | 11 |
| 13 const int KB = 1024; | 12 const int KB = 1024; |
| 14 const int MB = KB * KB; | 13 const int MB = KB * KB; |
| 15 const int GB = KB * KB * KB; | 14 const int GB = KB * KB * KB; |
| 16 | 15 |
| 17 class SlowConsumer extends StreamConsumer { | 16 class SlowConsumer extends StreamConsumer { |
| 18 int receivedCount = 0; | 17 int receivedCount = 0; |
| 19 final int bytesPerSecond; | 18 final int bytesPerSecond; |
| (...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 100 // file). If the consumer doesn't pause the data-provider it will run out of | 99 // file). If the consumer doesn't pause the data-provider it will run out of |
| 101 // heap-space. | 100 // heap-space. |
| 102 | 101 |
| 103 new DataProvider(800 * MB, 100 * MB, 1 * MB).stream | 102 new DataProvider(800 * MB, 100 * MB, 1 * MB).stream |
| 104 .pipe(new SlowConsumer(200 * MB, 5 * MB)) | 103 .pipe(new SlowConsumer(200 * MB, 5 * MB)) |
| 105 .then((count) { | 104 .then((count) { |
| 106 port.close(); | 105 port.close(); |
| 107 Expect.equals(100 * MB, count); | 106 Expect.equals(100 * MB, count); |
| 108 }); | 107 }); |
| 109 } | 108 } |
| OLD | NEW |