/** * Sets a time mark identified with $name * * @param string $name * @param bool $logFirst */ public function mark($name, $logFirst = false) { if (isset($this->marks[$name])) { $this->marks[$name]['time'] = round((microtime(true) - $_SERVER['REQUEST_TIME']) * 1000 - $this->marks[$name]['time']) . 'ms'; if (function_exists('memory_get_usage')) { $this->marks[$name]['memory'] = round((memory_get_usage() - $this->marks[$name]['memory']) / 1024) . 'K'; } else { $this->marks[$name]['memory'] = 'N/A'; } $this->logger->zflog(['time' => $this->marks[$name]['time'], 'memory' => $this->marks[$name]['memory'], 'message' => $name]); } else { $this->marks[$name]['time'] = (microtime(true) - $_SERVER['REQUEST_TIME']) * 1000; if (function_exists('memory_get_usage')) { $this->marks[$name]['memory'] = memory_get_usage(); } else { $this->marks[$name]['memory'] = 'N/A'; } if ($logFirst) { $this->logger->zflog(['time' => round($this->marks[$name]['time']) . 'ms', 'memory' => round($this->marks[$name]['memory'] / 1024) . 'K', 'message' => $name]); } } }