File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 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
1010use React \EventLoop \Factory ;
2626$ runs = 0 ;
2727
2828if (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
You can’t perform that action at this time.
0 commit comments