![]() Server : Apache System : Linux server2.corals.io 4.18.0-348.2.1.el8_5.x86_64 #1 SMP Mon Nov 15 09:17:08 EST 2021 x86_64 User : corals ( 1002) PHP Version : 7.4.33 Disable Function : exec,passthru,shell_exec,system Directory : /home/corals/demo.cartinsight.co/vendor/spatie/ray/src/Payloads/ |
<?php namespace Spatie\Ray\Payloads; use Symfony\Component\Stopwatch\StopwatchEvent; class MeasurePayload extends Payload { /** @var string */ protected $name; /** @var bool */ protected $isNewTimer = false; /** @var float|int */ protected $totalTime = 0; /** @var int */ protected $maxMemoryUsageDuringTotalTime = 0; /** @var float|int */ protected $timeSinceLastCall = 0; /** @var int */ protected $maxMemoryUsageSinceLastCall = 0; public function __construct(string $name, StopwatchEvent $stopwatchEvent) { $this->name = $name; $this->totalTime = $stopwatchEvent->getDuration(); $this->maxMemoryUsageDuringTotalTime = $stopwatchEvent->getMemory(); $periods = $stopwatchEvent->getPeriods(); if ($lastPeriod = end($periods)) { $this->timeSinceLastCall = $lastPeriod->getDuration() ; $this->maxMemoryUsageSinceLastCall = $lastPeriod->getMemory(); } } public function concernsNewTimer(): self { $this->isNewTimer = true; $this->totalTime = 0; $this->maxMemoryUsageDuringTotalTime = 0; $this->timeSinceLastCall = 0; $this->maxMemoryUsageSinceLastCall = 0; return $this; } public function getType(): string { return 'measure'; } public function getContent(): array { return [ 'name' => $this->name, 'is_new_timer' => $this->isNewTimer, 'total_time' => $this->totalTime, 'max_memory_usage_during_total_time' => $this->maxMemoryUsageDuringTotalTime, 'time_since_last_call' => $this->timeSinceLastCall, 'max_memory_usage_since_last_call' => $this->maxMemoryUsageSinceLastCall, ]; } }