/**
  * {@inheritdoc}
  */
 public function getValues() : PromiseInterface
 {
     $counters = $this->infoProvider->getCounters();
     $storage = new \SplObjectStorage();
     $storage->attach(new Metric('current_read_streams', (double) $counters['streams']['read']['current']));
     $storage->attach(new Metric('current_write_streams', (double) $counters['streams']['write']['current']));
     return resolve($storage);
 }
 /**
  * {@inheritdoc}
  */
 public function getValues() : PromiseInterface
 {
     $counters = $this->infoProvider->getCounters();
     $this->infoProvider->resetTotals();
     $storage = new \SplObjectStorage();
     $storage->attach(new Metric('streams_read_total', (double) $counters['streams']['read']['total']));
     $storage->attach(new Metric('streams_total_total', (double) $counters['streams']['total']['total']));
     $storage->attach(new Metric('streams_write_total', (double) $counters['streams']['write']['total']));
     $storage->attach(new Metric('timers_once_total', (double) $counters['timers']['once']['total']));
     $storage->attach(new Metric('timers_periodic_total', (double) $counters['timers']['periodic']['total']));
     $storage->attach(new Metric('ticks_future_total', (double) $counters['ticks']['future']['total']));
     $storage->attach(new Metric('ticks_next_total', (double) $counters['ticks']['next']['total']));
     return resolve($storage);
 }
コード例 #3
0
<?php

use React\EventLoop\Factory;
use React\EventLoop\Timer\TimerInterface;
use WyriHaximus\React\Inspector\InfoProvider;
use WyriHaximus\React\Inspector\LoopDecorator;
require 'vendor/autoload.php';
$loop = new LoopDecorator(Factory::create());
$info = new InfoProvider($loop);
for ($i = 1; $i <= 3; $i++) {
    $loop->addTimer($i, function () {
    });
    $loop->addPeriodicTimer(1.0E-5, function (TimerInterface $timer) use($loop) {
        if (mt_rand(0, 10000) == mt_rand(0, 10000)) {
            $loop->cancelTimer($timer);
        }
    });
    $loop->nextTick(function () use($loop) {
        $loop->nextTick(function () {
        });
    });
    $loop->futureTick(function () use($loop) {
        $loop->futureTick(function () {
        });
    });
}
$loop->run();
var_export($info->getCounters());