";
+ $rows[] = "" . $this->_format_value($data["hits"]) . " | ";
+ $rows[] = "" . $this->_size_for_humans($data["memory_consumption"]) . " | ";
+ $rows[] = $count > 1 ? "{$file} | " : "{$dir}/{$file} | ";
+ $rows[] = '
';
+ }
+
+ ++$id;
+ }
+
+ return implode("\n", $rows);
+ }
+
+ public function getScriptStatusCount()
+ {
+ return count($this->_status["scripts"]);
+ }
+
+ public function getGraphDataSetJson()
+ {
+ $dataset = array();
+ $dataset['memory'] = array(
+ $this->_status['memory_usage']['used_memory'],
+ $this->_status['memory_usage']['free_memory'],
+ $this->_status['memory_usage']['wasted_memory'],
+ );
+
+ $dataset['keys'] = array(
+ $this->_status['opcache_statistics']['num_cached_keys'],
+ $this->_status['opcache_statistics']['max_cached_keys'] - $this->_status['opcache_statistics']['num_cached_keys'],
+ 0
+ );
+
+ $dataset['hits'] = array(
+ $this->_status['opcache_statistics']['misses'],
+ $this->_status['opcache_statistics']['hits'],
+ 0,
+ );
+
+ $dataset['restarts'] = array(
+ $this->_status['opcache_statistics']['oom_restarts'],
+ $this->_status['opcache_statistics']['manual_restarts'],
+ $this->_status['opcache_statistics']['hash_restarts'],
+ );
+
+ if (THOUSAND_SEPARATOR === true) {
+ $dataset['TSEP'] = 1;
+ } else {
+ $dataset['TSEP'] = 0;
+ }
+
+ return json_encode($dataset);
+ }
+
+ public function getHumanUsedMemory()
+ {
+ return $this->_size_for_humans($this->getUsedMemory());
+ }
+
+ public function getHumanFreeMemory()
+ {
+ return $this->_size_for_humans($this->getFreeMemory());
+ }
+
+ public function getHumanWastedMemory()
+ {
+ return $this->_size_for_humans($this->getWastedMemory());
+ }
+
+ public function getUsedMemory()
+ {
+ return $this->_status['memory_usage']['used_memory'];
+ }
+
+ public function getFreeMemory()
+ {
+ return $this->_status['memory_usage']['free_memory'];
+ }
+
+ public function getWastedMemory()
+ {
+ return $this->_status['memory_usage']['wasted_memory'];
+ }
+
+ public function getWastedMemoryPercentage()
+ {
+ return number_format($this->_status['memory_usage']['current_wasted_percentage'], 2);
+ }
+
+ public function getD3Scripts()
+ {
+ return $this->_d3Scripts;
+ }
+
+ private function _processPartition($value, $name = null)
+ {
+ if (array_key_exists('size', $value)) {
+ return $value;
+ }
+
+ $array = array('name' => $name,'children' => array());
+
+ foreach ($value as $k => $v) {
+ $array['children'][] = $this->_processPartition($v, $k);
+ }
+
+ return $array;
+ }
+
+ private function _format_value($value)
+ {
+ if (THOUSAND_SEPARATOR === true) {
+ return number_format($value);
+ } else {
+ return $value;
+ }
+ }
+
+ private function _size_for_humans($bytes)
+ {
+ if ($bytes > 1048576) {
+ return sprintf('%.2f MB', $bytes / 1048576);
+ } else {
+ if ($bytes > 1024) {
+ return sprintf('%.2f kB', $bytes / 1024);
+ } else {
+ return sprintf('%d bytes', $bytes);
+ }
+ }
+ }
+
+ // Borrowed from Laravel
+ private function _arrayPset(&$array, $key, $value)
+ {
+ if (is_null($key)) return $array = $value;
+ $keys = explode(DIRECTORY_SEPARATOR, ltrim($key, DIRECTORY_SEPARATOR));
+ while (count($keys) > 1) {
+ $key = array_shift($keys);
+ if ( ! isset($array[$key]) || ! is_array($array[$key])) {
+ $array[$key] = array();
+ }
+ $array =& $array[$key];
+ }
+ $array[array_shift($keys)] = $value;
+ return $array;
+ }
+
+}
+
+$dataModel = new OpCacheDataModel();
+?>
+
+