Skip to content

Commit

Permalink
Update benchmark example
Browse files Browse the repository at this point in the history
  • Loading branch information
trowski committed May 11, 2017
1 parent cfbf25e commit fbf4b2e
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions examples/benchmark-throughput.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,12 +38,15 @@

$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);
}

Expand Down

5 comments on commit fbf4b2e

@kelunik
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

... please readd close() ...

@bwoebi
Copy link
Member

@bwoebi bwoebi commented on fbf4b2e May 12, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I thought we'd have an end() method instead?

@kelunik
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Where?

@bwoebi
Copy link
Member

@bwoebi bwoebi commented on fbf4b2e May 12, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's what I'm wondering too… thought it'd be added to the interface… confused a bit now.

@trowski
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I reverted this commit since close() is still a public method on ResourceInputStream. Let's discuss having the method in the interface in chat.

Please sign in to comment.