Jarves\EventListener\LatencyMonitorSubscriber::saveLatency PHP Method

saveLatency() public method

public saveLatency ( )
    public function saveLatency()
    {
        $lastLatency = $this->distributedCache->get('core/latency');
        $max = 20;
        $change = false;
        foreach (array('frontend', 'backend', 'cache', 'session') as $key) {
            if (!isset($this->latency[$key]) || !$this->latency[$key]) {
                continue;
            }
            $this->latency[$key] = array_sum($this->latency[$key]) / count($this->latency[$key]);
            $lastLatency[$key] = (array) @$lastLatency[$key] ?: array();
            array_unshift($lastLatency[$key], @$this->latency[$key]);
            if ($max < count($lastLatency[$key])) {
                array_splice($lastLatency[$key], $max);
            }
            $change = true;
        }
        if ($change) {
            $this->latency = array();
            $this->distributedCache->set('core/latency', $lastLatency);
        }
    }