aboutsummaryrefslogtreecommitdiffhomepage
path: root/assets/php/vendor/react/event-loop/examples/93-benchmark-ticks-delay.php
blob: 95ee78c68dfe071b80e626601f4356870cb58037 (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->addTimer(0, $tick);
        $loop->futureTick($tick);
    } else {
        echo 'done';
    }
};

$tick();

$loop->run();