Chromium Code Reviews| 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_consumer3_test; | 7 library slow_consumer3_test; |
| 8 | 8 |
| 9 import 'package:async_helper/async_helper.dart'; | 9 import 'package:async_helper/async_helper.dart'; |
| 10 import "package:expect/expect.dart"; | 10 import "package:expect/expect.dart"; |
| 11 import 'dart:async'; | 11 import 'dart:async'; |
| 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<List> { |
|
Bob Nystrom
2017/08/23 21:49:32
Use List<int> here and below?
| |
| 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 = []; |
| 22 int usedBufferSize = 0; | 22 int usedBufferSize = 0; |
| 23 int finalCount; | 23 int finalCount; |
| 24 | 24 |
| 25 SlowConsumer(int this.bytesPerSecond, int this.bufferSize); | 25 SlowConsumer(int this.bytesPerSecond, int this.bufferSize); |
| 26 | 26 |
| 27 Future consume(Stream stream) { | 27 Future consume(Stream stream) { |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 83 // file). If the consumer doesn't pause the data-provider it will run out of | 83 // file). If the consumer doesn't pause the data-provider it will run out of |
| 84 // heap-space. | 84 // heap-space. |
| 85 | 85 |
| 86 dataGenerator(100 * MB, 512 * KB) | 86 dataGenerator(100 * MB, 512 * KB) |
| 87 .pipe(new SlowConsumer(200 * MB, 3 * MB)) | 87 .pipe(new SlowConsumer(200 * MB, 3 * MB)) |
| 88 .then((count) { | 88 .then((count) { |
| 89 Expect.equals(100 * MB, count); | 89 Expect.equals(100 * MB, count); |
| 90 asyncEnd(); | 90 asyncEnd(); |
| 91 }); | 91 }); |
| 92 } | 92 } |
| OLD | NEW |