1
0
mirror of https://github.com/danog/byte-stream.git synced 2024-11-26 20:04:51 +01:00

Update benchmark example

This commit is contained in:
Aaron Piotrowski 2017-05-11 18:14:33 -05:00
parent cfbf25e3b5
commit fbf4b2ef64

View File

@ -38,12 +38,15 @@ try {
$stderr->write('piping from ' . $if . ' to ' . $of . ' (for max ' . $t . ' second(s)) ...'. PHP_EOL);
Loop::delay($t * 1000, [$in, "close"]);
$running = true;
Loop::delay($t * 1000, function () use (&$running) {
$running = false;
});
Loop::run(function () use ($stderr, $in, $out) {
Loop::run(function () use (&$running, $stderr, $in, $out) {
$start = microtime(true);
while (($chunk = yield $in->read()) !== null) {
while ($running && ($chunk = yield $in->read()) !== null) {
yield $out->write($chunk);
}