/** * Benchmark * * @staticvar type $start * @staticvar int $total * @param string $name */ public static function benchmark($name = '') { if (self::$debug) { static $start = NULL; static $total = 0; $benchmark = 0; if (is_null($start)) { $start = self::get_microtime(); } else { $temp = self::get_microtime(); $benchmark = $temp - $start; $start = $temp; } $total += $benchmark; self::$data['benchmark'][] = ['name' => $name, 'time' => format::time_seconds($benchmark) . '', 'total' => format::time_seconds($total), 'start' => format::datetime($start), 'memory' => memory_get_peak_usage(true)]; } }
// we need to reset all caches if ($mode == 'commit') { $cache = factory::get(['cache']); if (!empty($cache)) { foreach ($cache as $k => $v) { $object = $v['object']; $object->gc(2); } } } break; case 'dependency': default: $result = system_dependencies::process_deps_all(['mode' => $mode]); } // hint if (!empty($result['hint'])) { echo implode("\n", $result['hint']) . "\n"; } // if we did not succede if (!$result['success']) { echo implode("\n", $result['error']) . "\n"; exit; } } catch (Exception $e) { echo $e->getMessage() . "\n"; } // benchmark $seconds = format::time_seconds(microtime(true) - $benchmark); // if we succedded echo "\nOperation \"{$type}\" with mode \"{$mode}\" completed in {$seconds} seconds!\n";