8000 Merge pull request #143 from jsor-labs/fix-memory-benchmark · Undefined-Variables/event-loop@914304f · GitHub
[go: up one dir, main page]

Skip to content

Commit 914304f

Browse files
authored
Merge pull request reactphp#143 from jsor-labs/fix-memory-benchmark
Fix memory benchmark
2 parents e18ee06 + a6aae86 commit 914304f

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

examples/95-benchmark-memory.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@
22

33
/**
44
* Run the script indefinitely seconds with the loop from the factory and report every 2 seconds:
5-
* php test-memory.php
5+
* php 95-benchmark-memory.php
66
* Run the script for 30 seconds with the stream_select loop and report every 10 seconds:
7-
* php test-memory.php -t 30 -l StreamSelect -r 10
7+
* php 95-benchmark-memory.php -t 30 -l StreamSelect -r 10
88
*/
99

1010
use React\EventLoop\Factory;
@@ -26,17 +26,17 @@
2626
$runs = 0;
2727

2828
if (5 < $t) {
29-
$loop->addTimer($t, function (TimerInterface $timer) {
30-
$timer->getLoop()->stop();
29+
$loop->addTimer($t, function () use ($loop) {
30+
$loop->stop();
3131
});
3232

3333
}
3434

3535
$loop->addPeriodicTimer(0.001, function () use (&$runs, $loop) {
3636
$runs++;
3737

38-
$loop->addPeriodicTimer(1, function (TimerInterface $timer) {
39-
$timer->cancel();
38+
$loop->addPeriodicTimer(1, function (TimerInterface $timer) use ($loop) {
39+
$loop->cancelTimer($timer);
4040
});
4141
});
4242

0 commit comments

Comments
 (0)
0