set('config_profiler', true); } // Install if (!defined('DIR_APPLICATION')) { header('Location: install/index.php'); exit; } // Startup require_once(DIR_SYSTEM . 'startup.php'); global $controllers_time; global $stack_time; $controllers_time = []; $stack_time = 0; // $registry->set('time_start', $time_start); // $registry->set('models_time', []); // $registry->set('controllers_time', []); // // Оборачиваем DB для логирования // $registry->get('db')->query_log = []; start('catalog'); if ($_SERVER['REMOTE_ADDR'] === '212.90.36.16') { echo "
";
    echo "=== PROFILER ===\n";

    global $controllers_time;

    // Список контроллеров и их время
    if (!empty($controllers_time)) {
        foreach ($controllers_time as $route => $time) {
            echo sprintf("%-100s %.5f sec\n", $route, $time);
        }
    }

    if (!empty($controllers_time['__details'])) {
    echo "=== CONTROLLER DETAILS ===\n";
    foreach ($controllers_time['__details'] as $route => $detail) {
        echo ">>> $route\n";
        foreach ($detail as $k => $v) {
            echo sprintf("   %-25s %.5f sec\n", $k, $v);
        }
    }
}

$total_query = 0;

	// SQL-профайлер
    if (!empty(\DB\MySQLi::$queries_time)) {
        echo "=== SQL QUERIES ===\n";
        foreach (\DB\MySQLi::$queries_time as $q) {
        	$sql_one_line = preg_replace('/\s+/', ' ', trim($q['sql']));
            echo number_format($q['time'], 5) . " sec | " . $sql_one_line . "\n";
            $total_query+=number_format($q['time'], 5);
        }
    }

	// Cache profiler
	if (!empty(SQLFileCache::$cache_time)) {
	    echo "=== CACHE READS ===\n";
	    foreach (SQLFileCache::$cache_time as $c) {
	    	$sql_one_line = preg_replace('/\s+/', ' ', trim($c['sql']));
	        echo number_format($c['time'], 5) . " sec | " . $sql_one_line.  " | " . $c['file'] . "\n";
            $total_query+=number_format($c['time'], 5);
	    }
	}

    // Общее время
    $total = microtime(true) - $__page_start;
    echo "\n=== TOTAL QUERIES: " . number_format($total_query, 5) . " sec ===\n";
    echo "\n=== TOTAL TIME: " . number_format($total, 5) . " sec ===\n";
    echo "
"; }