aboutsummaryrefslogtreecommitdiffhomepage
path: root/assets/php/vendor/react/event-loop/examples/94-benchmark-timers-delay.php
blob: 2d6cfa25dc03ba3056e19c20fef80447389d5ac2 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
<?php

use React\EventLoop\Factory;

require __DIR__ . '/../vendor/autoload.php';

$loop = Factory::create();

$ticks = isset($argv[1]) ? (int)$argv[1] : 1000 * 100;
$tick = function () use (&$tick, &$ticks, $loop) {
    if ($ticks > 0) {
        --$ticks;
        //$loop->futureTick($tick);
        $loop->addTimer(0, $tick);
    } else {
        echo 'done';
    }
};

$tick();

$loop->run();