| 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=32 | 5 // VMOptions=--old_gen_heap_size=32 |
| 6 | 6 |
| 7 library slow_consumer3_test; | 7 library slow_consumer3_test; |
| 8 | 8 |
| 9 import 'dart:async'; | 9 import 'dart:async'; |
| 10 import 'dart:isolate'; | 10 import 'dart:isolate'; |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 52 int chunks = bytesTotal ~/ chunkSize; | 52 int chunks = bytesTotal ~/ chunkSize; |
| 53 return new Stream.fromIterable(new Iterable.generate(chunks, (_) { | 53 return new Stream.fromIterable(new Iterable.generate(chunks, (_) { |
| 54 // This assumes one byte per entry. In practice it will be more. | 54 // This assumes one byte per entry. In practice it will be more. |
| 55 return new List<int>.fixedLength(chunkSize); | 55 return new List<int>.fixedLength(chunkSize); |
| 56 })); | 56 })); |
| 57 } | 57 } |
| 58 | 58 |
| 59 main() { | 59 main() { |
| 60 var port = new ReceivePort(); | 60 var port = new ReceivePort(); |
| 61 // The data provider can deliver 800MBs of data as fast as it is | 61 // The data provider can deliver 800MBs of data as fast as it is |
| 62 // requested. The data is sent in 1MB chunks. The consumer has a buffer of | 62 // requested. The data is sent in 0.5MB chunks. The consumer has a buffer of |
| 63 // 5MB. That is, it can accept a few packages without pausing its input. | 63 // 3MB. That is, it can accept a few packages without pausing its input. |
| 64 // |
| 65 // Notice that we aren't really counting bytes, but words, since we use normal |
| 66 // lists where each entry takes up a full word. In 64-bit VMs this will be |
| 67 // 8 bytes per entry, so the 3*MB buffer is picked to stay below 32 actual |
| 68 // MiB. |
| 64 // | 69 // |
| 65 // This test is limited to 32MB of heap-space (see VMOptions on top of the | 70 // This test is limited to 32MB of heap-space (see VMOptions on top of the |
| 66 // file). If the consumer doesn't pause the data-provider it will run out of | 71 // file). If the consumer doesn't pause the data-provider it will run out of |
| 67 // heap-space. | 72 // heap-space. |
| 68 | 73 |
| 69 dataGenerator(100 * MB, 1 * MB) | 74 dataGenerator(100 * MB, 512 * KB) |
| 70 .pipe(new SlowConsumer(200 * MB, 5 * MB)) | 75 .pipe(new SlowConsumer(200 * MB, 3 * MB)) |
| 71 .then((count) { | 76 .then((count) { |
| 72 port.close(); | 77 port.close(); |
| 73 Expect.equals(100 * MB, count); | 78 Expect.equals(100 * MB, count); |
| 74 }); | 79 }); |
| 75 } | 80 } |
| OLD | NEW |