| @@ 14-107 (lines=94) @@ | ||
| 11 | use WyriHaximus\React\Inspector\InfoProvider; |
|
| 12 | use function React\Promise\resolve; |
|
| 13 | ||
| 14 | class Ticks implements PluginInterface |
|
| 15 | { |
|
| 16 | /** |
|
| 17 | * @var InfoProvider |
|
| 18 | */ |
|
| 19 | protected $infoProvider; |
|
| 20 | ||
| 21 | /** |
|
| 22 | * @var Configuration |
|
| 23 | */ |
|
| 24 | protected $configuration; |
|
| 25 | ||
| 26 | /** |
|
| 27 | * Info constructor. |
|
| 28 | * @param InfoProvider $infoProvider |
|
| 29 | */ |
|
| 30 | public function __construct(InfoProvider $infoProvider) |
|
| 31 | { |
|
| 32 | $this->infoProvider = $infoProvider; |
|
| 33 | } |
|
| 34 | ||
| 35 | /** |
|
| 36 | * {@inheritdoc} |
|
| 37 | */ |
|
| 38 | public function setNode(Node $node) |
|
| 39 | { |
|
| 40 | $this->node = $node; |
|
| 41 | } |
|
| 42 | ||
| 43 | /** |
|
| 44 | * {@inheritdoc} |
|
| 45 | */ |
|
| 46 | public function getSlug(): string |
|
| 47 | { |
|
| 48 | return 'event_loop_ticks'; |
|
| 49 | } |
|
| 50 | ||
| 51 | /** |
|
| 52 | * {@inheritdoc} |
|
| 53 | */ |
|
| 54 | public function getCategorySlug(): string |
|
| 55 | { |
|
| 56 | return 'event_loop'; |
|
| 57 | } |
|
| 58 | ||
| 59 | /** |
|
| 60 | * {@inheritdoc} |
|
| 61 | */ |
|
| 62 | public function getCapabilities(): array |
|
| 63 | { |
|
| 64 | return []; |
|
| 65 | } |
|
| 66 | ||
| 67 | /** |
|
| 68 | * {@inheritdoc} |
|
| 69 | */ |
|
| 70 | public function getConfiguration(): PromiseInterface |
|
| 71 | { |
|
| 72 | if ($this->configuration instanceof Configuration) { |
|
| 73 | return resolve($this->configuration); |
|
| 74 | } |
|
| 75 | ||
| 76 | $this->configuration = new Configuration(); |
|
| 77 | $this->configuration->setPair('graph_category', 'event_loop'); |
|
| 78 | $this->configuration->setPair('graph_title', 'Callbacks Ticks'); |
|
| 79 | $this->configuration->setPair('streams_read_ticks.label', 'Read Stream ticks'); |
|
| 80 | $this->configuration->setPair('streams_total_ticks.label', 'Total Stream ticks'); |
|
| 81 | $this->configuration->setPair('streams_write_ticks.label', 'Write Stream ticks'); |
|
| 82 | $this->configuration->setPair('timers_once_ticks.label', 'One-off Timer ticks'); |
|
| 83 | $this->configuration->setPair('timers_periodic_ticks.label', 'Periodic Timer ticks'); |
|
| 84 | $this->configuration->setPair('ticks_future_ticks.label', 'Future ticks'); |
|
| 85 | $this->configuration->setPair('ticks_next_ticks.label', 'Next ticks'); |
|
| 86 | ||
| 87 | return resolve($this->configuration); |
|
| 88 | } |
|
| 89 | ||
| 90 | /** |
|
| 91 | * {@inheritdoc} |
|
| 92 | */ |
|
| 93 | public function getValues(): PromiseInterface |
|
| 94 | { |
|
| 95 | $counters = $this->infoProvider->getCounters(); |
|
| 96 | $this->infoProvider->resetTicks(); |
|
| 97 | $storage = new \SplObjectStorage(); |
|
| 98 | $storage->attach(new Metric('streams_read_ticks', (float)$counters['streams']['read']['ticks'])); |
|
| 99 | $storage->attach(new Metric('streams_total_ticks', (float)$counters['streams']['total']['ticks'])); |
|
| 100 | $storage->attach(new Metric('streams_write_ticks', (float)$counters['streams']['write']['ticks'])); |
|
| 101 | $storage->attach(new Metric('timers_once_ticks', (float)$counters['timers']['once']['ticks'])); |
|
| 102 | $storage->attach(new Metric('timers_periodic_ticks', (float)$counters['timers']['periodic']['ticks'])); |
|
| 103 | $storage->attach(new Metric('ticks_future_ticks', (float)$counters['ticks']['future']['ticks'])); |
|
| 104 | $storage->attach(new Metric('ticks_next_ticks', (float)$counters['ticks']['next']['ticks'])); |
|
| 105 | return resolve($storage); |
|
| 106 | } |
|
| 107 | } |
|
| 108 | ||
| @@ 14-107 (lines=94) @@ | ||
| 11 | use WyriHaximus\React\Inspector\InfoProvider; |
|
| 12 | use function React\Promise\resolve; |
|
| 13 | ||
| 14 | class Totals implements PluginInterface |
|
| 15 | { |
|
| 16 | /** |
|
| 17 | * @var InfoProvider |
|
| 18 | */ |
|
| 19 | protected $infoProvider; |
|
| 20 | ||
| 21 | /** |
|
| 22 | * @var Configuration |
|
| 23 | */ |
|
| 24 | protected $configuration; |
|
| 25 | ||
| 26 | /** |
|
| 27 | * Info constructor. |
|
| 28 | * @param InfoProvider $infoProvider |
|
| 29 | */ |
|
| 30 | public function __construct(InfoProvider $infoProvider) |
|
| 31 | { |
|
| 32 | $this->infoProvider = $infoProvider; |
|
| 33 | } |
|
| 34 | ||
| 35 | /** |
|
| 36 | * {@inheritdoc} |
|
| 37 | */ |
|
| 38 | public function setNode(Node $node) |
|
| 39 | { |
|
| 40 | $this->node = $node; |
|
| 41 | } |
|
| 42 | ||
| 43 | /** |
|
| 44 | * {@inheritdoc} |
|
| 45 | */ |
|
| 46 | public function getSlug(): string |
|
| 47 | { |
|
| 48 | return 'event_loop_totals'; |
|
| 49 | } |
|
| 50 | ||
| 51 | /** |
|
| 52 | * {@inheritdoc} |
|
| 53 | */ |
|
| 54 | public function getCategorySlug(): string |
|
| 55 | { |
|
| 56 | return 'event_loop'; |
|
| 57 | } |
|
| 58 | ||
| 59 | /** |
|
| 60 | * {@inheritdoc} |
|
| 61 | */ |
|
| 62 | public function getCapabilities(): array |
|
| 63 | { |
|
| 64 | return []; |
|
| 65 | } |
|
| 66 | ||
| 67 | /** |
|
| 68 | * {@inheritdoc} |
|
| 69 | */ |
|
| 70 | public function getConfiguration(): PromiseInterface |
|
| 71 | { |
|
| 72 | if ($this->configuration instanceof Configuration) { |
|
| 73 | return resolve($this->configuration); |
|
| 74 | } |
|
| 75 | ||
| 76 | $this->configuration = new Configuration(); |
|
| 77 | $this->configuration->setPair('graph_category', 'event_loop'); |
|
| 78 | $this->configuration->setPair('graph_title', 'Totals'); |
|
| 79 | $this->configuration->setPair('streams_read_total.label', 'Read Streams'); |
|
| 80 | $this->configuration->setPair('streams_total_total.label', 'Total Streams'); |
|
| 81 | $this->configuration->setPair('streams_write_total.label', 'Write Streams'); |
|
| 82 | $this->configuration->setPair('timers_once_total.label', 'One-off Timers'); |
|
| 83 | $this->configuration->setPair('timers_periodic_total.label', 'Periodic Timers'); |
|
| 84 | $this->configuration->setPair('ticks_future_total.label', 'Future ticks'); |
|
| 85 | $this->configuration->setPair('ticks_next_total.label', 'Next ticks'); |
|
| 86 | ||
| 87 | return resolve($this->configuration); |
|
| 88 | } |
|
| 89 | ||
| 90 | /** |
|
| 91 | * {@inheritdoc} |
|
| 92 | */ |
|
| 93 | public function getValues(): PromiseInterface |
|
| 94 | { |
|
| 95 | $counters = $this->infoProvider->getCounters(); |
|
| 96 | $this->infoProvider->resetTotals(); |
|
| 97 | $storage = new \SplObjectStorage(); |
|
| 98 | $storage->attach(new Metric('streams_read_total', (float)$counters['streams']['read']['total'])); |
|
| 99 | $storage->attach(new Metric('streams_total_total', (float)$counters['streams']['total']['total'])); |
|
| 100 | $storage->attach(new Metric('streams_write_total', (float)$counters['streams']['write']['total'])); |
|
| 101 | $storage->attach(new Metric('timers_once_total', (float)$counters['timers']['once']['total'])); |
|
| 102 | $storage->attach(new Metric('timers_periodic_total', (float)$counters['timers']['periodic']['total'])); |
|
| 103 | $storage->attach(new Metric('ticks_future_total', (float)$counters['ticks']['future']['total'])); |
|
| 104 | $storage->attach(new Metric('ticks_next_total', (float)$counters['ticks']['next']['total'])); |
|
| 105 | return resolve($storage); |
|
| 106 | } |
|
| 107 | } |
|
| 108 | ||