🛑 Security Halt

For your safety, this script is disabled until you change the default password.

Please open this file in a text editor and change $ADMIN_PASSWORD to something unique.

Default password detected: password

HTML ); } // ============================================================================ // STYLING & UI FUNCTIONS // ============================================================================ /** * Returns the main CSS stylesheet with theme variables * Supports both light and dark mode * * @return string CSS stylesheet content */ function get_main_css() { return << Login Required

🔒 Login Required

'shared', 'has_proc_access' => false, 'has_system_access' => false, 'restrictions' => [] ]; if (@is_readable('/proc/cpuinfo') && @is_readable('/proc/meminfo') && @is_readable('/proc/uptime')) { $env['has_proc_access'] = true; $env['type'] = 'vps'; } if (function_exists('shell_exec') && !in_array('shell_exec', array_map('trim', explode(',', ini_get('disable_functions'))))) { $test = @shell_exec('echo test 2>&1'); if (trim($test) === 'test') { $env['has_system_access'] = true; $env['type'] = 'dedicated'; } } $open_basedir = ini_get('open_basedir'); if (!empty($open_basedir)) { $env['restrictions'][] = 'open_basedir'; } $disabled_functions = ini_get('disable_functions'); if (!empty($disabled_functions)) { $env['restrictions'][] = 'disabled_functions'; } return $env; } /** * Get CPU information including model, cores, frequency, and cache * Falls back to PHP limits on restricted shared hosting * * @return array CPU information */ function get_cpu_info() { $cpu = [ 'model' => 'N/A', 'cores' => 1, 'mhz' => '', 'cache' => '', 'bogomips' => '', 'restricted' => false ]; if (@is_readable('/proc/cpuinfo')) { $cpuinfo = @file_get_contents('/proc/cpuinfo'); if ($cpuinfo) { if (preg_match('/model name\s*:\s*(.+)/i', $cpuinfo, $match)) { $cpu['model'] = trim($match[1]); } if (preg_match('/cpu MHz\s*:\s*([\d\.]+)/i', $cpuinfo, $match)) { $cpu['mhz'] = round($match[1] / 1000, 3); } if (preg_match('/cache size\s*:\s*([\d]+)\s*KB/i', $cpuinfo, $match)) { $cpu['cache'] = $match[1]; } if (preg_match('/bogomips\s*:\s*([\d\.]+)/i', $cpuinfo, $match)) { $cpu['bogomips'] = $match[1]; } $cpu['cores'] = substr_count($cpuinfo, 'processor'); } } else { $cpu['model'] = 'N/A - Restricted on shared hosting'; $cpu['restricted'] = true; } return $cpu; } /** * Calculate CPU usage percentages by reading /proc/stat * Measures user, system, idle, and other CPU states * * @return array CPU usage percentages */ function get_cpu_usage() { $cpu_usage = ['user' => 0, 'sys' => 0, 'nice' => 0, 'idle' => 0, 'iowait' => 0, 'irq' => 0, 'softirq' => 0]; if (@is_readable('/proc/stat')) { $stat1 = @file_get_contents('/proc/stat'); if ($stat1 && preg_match('/^cpu\s+(\d+)\s+(\d+)\s+(\d+)\s+(\d+)\s+(\d+)\s+(\d+)\s+(\d+)/m', $stat1, $matches1)) { usleep(100000); // 0.1 seconds - efficient for live dashboard $stat2 = @file_get_contents('/proc/stat'); if ($stat2 && preg_match('/^cpu\s+(\d+)\s+(\d+)\s+(\d+)\s+(\d+)\s+(\d+)\s+(\d+)\s+(\d+)/m', $stat2, $matches2)) { $dif = []; $dif['user'] = $matches2[1] - $matches1[1]; $dif['nice'] = $matches2[2] - $matches1[2]; $dif['sys'] = $matches2[3] - $matches1[3]; $dif['idle'] = $matches2[4] - $matches1[4]; $dif['iowait'] = $matches2[5] - $matches1[5]; $dif['irq'] = $matches2[6] - $matches1[6]; $dif['softirq'] = $matches2[7] - $matches1[7]; $total = array_sum($dif); if ($total > 0) { foreach ($dif as $key => $val) { $cpu_usage[$key] = round(($val / $total) * 100, 0); } } } } } return $cpu_usage; } /** * Get system memory information including total, used, free, cached, and swap * Falls back to PHP memory_limit on restricted shared hosting * * @return array Memory information in MB */ function get_memory_info() { $memory = [ 'total' => 0, 'free' => 0, 'used' => 0, 'percent' => 0, 'buffers' => 0, 'cached' => 0, 'real_used' => 0, 'real_free' => 0, 'real_percent' => 0, 'swap_total' => 0, 'swap_used' => 0, 'swap_free' => 0, 'swap_percent' => 0, 'restricted' => false, 'is_php_limit' => false ]; if (@is_readable('/proc/meminfo')) { $meminfo = @file_get_contents('/proc/meminfo'); if ($meminfo) { if (preg_match('/MemTotal:\s+(\d+)\s+kB/i', $meminfo, $match)) { $memory['total'] = round($match[1] / 1024, 2); } if (preg_match('/MemFree:\s+(\d+)\s+kB/i', $meminfo, $match)) { $memory['free'] = round($match[1] / 1024, 2); } if (preg_match('/Buffers:\s+(\d+)\s+kB/i', $meminfo, $match)) { $memory['buffers'] = round($match[1] / 1024, 2); } if (preg_match('/^Cached:\s+(\d+)\s+kB/im', $meminfo, $match)) { $memory['cached'] = round($match[1] / 1024, 2); } if (preg_match('/SwapTotal:\s+(\d+)\s+kB/i', $meminfo, $match)) { $memory['swap_total'] = round($match[1] / 1024, 2); } if (preg_match('/SwapFree:\s+(\d+)\s+kB/i', $meminfo, $match)) { $memory['swap_free'] = round($match[1] / 1024, 2); } $memory['used'] = $memory['total'] - $memory['free']; $memory['percent'] = $memory['total'] > 0 ? round(($memory['used'] / $memory['total']) * 100, 2) : 0; $memory['real_used'] = $memory['total'] - $memory['free'] - $memory['cached'] - $memory['buffers']; $memory['real_free'] = $memory['total'] - $memory['real_used']; $memory['real_percent'] = $memory['total'] > 0 ? round(($memory['real_used'] / $memory['total']) * 100, 2) : 0; $memory['swap_used'] = $memory['swap_total'] - $memory['swap_free']; $memory['swap_percent'] = $memory['swap_total'] > 0 ? round(($memory['swap_used'] / $memory['swap_total']) * 100, 2) : 0; } } else { $memory['restricted'] = true; $memory['is_php_limit'] = true; $limit = ini_get('memory_limit'); if ($limit == '-1') { $memory['total'] = 512; } elseif (preg_match('/^(\d+)(.)$/', $limit, $matches)) { $memory_limit_mb = $matches[1]; if (strtoupper($matches[2]) == 'G') { $memory_limit_mb *= 1024; } elseif (strtoupper($matches[2]) == 'K') { $memory_limit_mb /= 1024; } $memory['total'] = $memory_limit_mb; } if (function_exists('memory_get_usage')) { $memory['used'] = round(memory_get_usage(true) / 1024 / 1024, 2); $memory['free'] = $memory['total'] - $memory['used']; $memory['percent'] = $memory['total'] > 0 ? round(($memory['used'] / $memory['total']) * 100, 2) : 0; $memory['real_used'] = $memory['used']; $memory['real_free'] = $memory['free']; $memory['real_percent'] = $memory['percent']; } } return $memory; } /** * Get system uptime from /proc/uptime * * @return string Formatted uptime string (e.g., "5 Days 12 Hours 30 Minutes") */ function get_uptime() { if (@is_readable('/proc/uptime')) { $uptime = @file_get_contents('/proc/uptime'); if ($uptime) { $uptime_seconds = (int)explode(' ', $uptime)[0]; $days = floor($uptime_seconds / 86400); $hours = floor(($uptime_seconds % 86400) / 3600); $minutes = floor(($uptime_seconds % 3600) / 60); $result = ''; if ($days > 0) $result .= $days . ' Days '; if ($hours > 0) $result .= $hours . ' Hours '; $result .= $minutes . ' Minutes'; return $result; } } return 'N/A - Restricted on shared hosting'; } /** * Get system load average (1min, 5min, 15min) * * @return string Load average values */ function get_load_average() { if (function_exists('sys_getloadavg')) { $load = sys_getloadavg(); return implode(' ', array_map(function($v) { return round($v, 2); }, $load)); } if (@is_readable('/proc/loadavg')) { $load = @file_get_contents('/proc/loadavg'); if ($load) { $parts = explode(' ', $load); return $parts[0] . ' ' . $parts[1] . ' ' . $parts[2] . ' ' . $parts[3]; } } return 'N/A'; } /** * Get network interface statistics (RX/TX bytes) * Reads from /proc/net/dev * * @return array Network interfaces with RX/TX data */ function get_network_info() { $interfaces = []; if (@is_readable('/proc/net/dev')) { $net_dev = @file('/proc/net/dev'); if ($net_dev) { foreach ($net_dev as $line) { if (preg_match('/^\s*([^:]+):\s*(\d+)\s+\d+\s+\d+\s+\d+\s+\d+\s+\d+\s+\d+\s+\d+\s+(\d+)/', $line, $match)) { $interface = trim($match[1]); $interfaces[$interface] = [ 'rx' => (int)$match[2], 'tx' => (int)$match[3] ]; } } } } return $interfaces; } // ============================================================================ // BENCHMARK FUNCTIONS - SCORING // ============================================================================ /** * Calculate performance score (0-10) based on execution time * Uses tiered scoring: excellent (9-10), good (7-9), average (5-7), poor (2-5), very poor (0-2) * * @param float $time Execution time in seconds * @param float $excellent Threshold for excellent performance * @param float $good Threshold for good performance * @param float $average Threshold for average performance * @param float $poor Threshold for poor performance * @return float Score from 0 to 10 */ /** * Scoring thresholds for different benchmark modes * Format: [excellent, good, average, poor] in seconds */ $SCORING_THRESHOLDS = [ 'modern' => [ // CPU & Memory Tests 'cpu_int' => [0.4, 0.9, 1.8, 3.0], 'cpu_float' => [0.5, 1.0, 1.8, 3.5], 'cpu_text' => [0.35, 0.7, 1.4, 3.0], 'cpu_binary' => [0.12, 0.25, 0.6, 1.5], 'string' => [0.03, 0.08, 0.25, 0.6], 'array' => [0.4, 0.9, 1.8, 3.5], 'hash' => [0.25, 0.6, 1.2, 2.5], 'json' => [0.3, 0.7, 1.5, 3.5], // Filesystem Tests 'io' => [0.008, 0.04, 0.15, 0.5], 'fs_write' => [0.1, 0.25, 0.6, 1.5], 'fs_copy' => [0.2, 0.5, 1.2, 3.0], 'fs_small' => [0.15, 0.5, 1.5, 4.0], // Database Tests 'db_import' => [0.01, 0.03, 0.10, 0.4], 'db_simple' => [0.02, 0.08, 0.25, 0.8], 'db_complex' => [0.15, 0.4, 1.0, 2.5], // Cache Tests 'opcache_performance' => [0.01, 0.05, 0.15, 0.4], 'cache_write' => [0.02, 0.06, 0.15, 0.4], 'cache_read' => [0.015, 0.04, 0.10, 0.25], 'cache_mixed' => [0.018, 0.05, 0.12, 0.30], // Network Tests 'network' => [0.1, 0.3, 0.8, 2.0], 'network_latency_ms' => [2, 10, 40, 100], // Note: in milliseconds 'concurrency' => [0.0005, 0.002, 0.01, 0.1], // Advanced Tests (add these new ones) 'regex' => [0.5, 1.2, 2.5, 5.0], 'large_json' => [0.8, 2.0, 4.0, 8.0], 'xml_parsing' => [0.6, 1.5, 3.0, 6.0], 'password_hashing' => [3.0, 5.0, 8.0, 12.0], // Intentionally slow 'datetime' => [0.5, 1.2, 2.5, 5.0], 'csv' => [0.3, 0.8, 2.0, 4.0], 'session' => [0.4, 1.0, 2.5, 5.0], 'image' => [0.8, 2.0, 4.0, 8.0] ], 'light' => [ // Use current/original thresholds 'cpu_int' => [0.8, 1.5, 3.0, 6.0], 'cpu_float' => [0.8, 1.8, 3.5, 7.0], 'cpu_text' => [0.8, 2.0, 4.0, 8.0], 'cpu_binary' => [0.5, 1.5, 3.0, 6.0], 'string' => [0.5, 1.5, 3.0, 6.0], 'array' => [0.8, 2.0, 4.0, 8.0], 'hash' => [0.8, 1.8, 3.5, 7.0], 'json' => [0.8, 2.0, 4.0, 8.0], 'io' => [0.2, 0.5, 1.0, 2.0], 'fs_write' => [0.8, 1.8, 3.5, 7.0], 'fs_copy' => [1.0, 2.5, 5.0, 9.0], 'fs_small' => [1.5, 3.5, 7.0, 12.0], 'db_import' => [0.8, 1.8, 3.5, 7.0], 'db_simple' => [0.5, 1.2, 2.5, 5.0], 'db_complex' => [0.8, 2.0, 4.0, 8.0], 'opcache_performance' => [0.5, 1.5, 3.0, 5.0], 'cache_write' => [0.1, 0.25, 0.5, 1.0], 'cache_read' => [0.08, 0.2, 0.4, 0.8], 'cache_mixed' => [0.09, 0.22, 0.45, 0.9], 'network' => [2.0, 4.0, 7.0, 12.0], 'network_latency_ms' => [50, 150, 300, 500], 'concurrency' => [0.1, 0.3, 0.8, 1.5], 'regex' => [2.0, 4.5, 8.0, 14.0], 'large_json' => [3.0, 6.0, 10.0, 16.0], 'xml_parsing' => [2.5, 5.0, 9.0, 15.0], 'password_hashing' => [8.0, 12.0, 18.0, 25.0], 'datetime' => [2.5, 5.0, 8.0, 13.0], 'csv' => [1.5, 3.5, 6.0, 10.0], 'session' => [2.0, 4.5, 8.0, 14.0], 'image' => [3.0, 6.0, 10.0, 16.0] ] ]; function calculate_score($time, $excellent, $good, $average, $poor, $aggressive = true) { if ($time <= 0) return 0; if ($aggressive) { // Modern 2025 scoring curve - stricter if ($time <= $excellent) { $ratio = $time / $excellent; return 10 - ($ratio * 1.0); // 10 to 9 } elseif ($time <= $good) { $ratio = ($time - $excellent) / ($good - $excellent); return 9 - ($ratio * 2); // 9 to 7 } elseif ($time <= $average) { $ratio = ($time - $good) / ($average - $good); return 7 - ($ratio * 3); // 7 to 4 } elseif ($time <= $poor) { $ratio = ($time - $average) / ($poor - $average); return 4 - ($ratio * 3); // 4 to 1 } else { return max(0, 1 - (($time - $poor) / $poor)); // 1 to 0 } } else { // Legacy scoring curve - more generous if ($time <= $excellent) { $ratio = $time / $excellent; return min(10, 9 + (1 - $ratio)); } elseif ($time <= $good) { $ratio = ($time - $excellent) / ($good - $excellent); return 9 - ($ratio * 2); } elseif ($time <= $average) { $ratio = ($time - $good) / ($average - $good); return 7 - ($ratio * 2); } elseif ($time <= $poor) { $ratio = ($time - $average) / ($poor - $average); return 5 - ($ratio * 3); } else { $ratio = min(($time - $poor) / $poor, 1); return max(0, 2 - ($ratio * 2)); } } } // ============================================================================ // BENCHMARK FUNCTIONS - CPU PERFORMANCE // ============================================================================ /** * Benchmark CPU performance with large text processing operations * Tests string manipulation, case conversion, search, and replace operations * * @return float Execution time in seconds */ function benchmark_cpu_operations_large_text() { $start = microtime(true); $maxTime = 15.0; $text = str_repeat('Lorem ipsum dolor sit amet, consectetur adipiscing elit. Praesent vitae eros eget tellus tristique bibendum. ', 2000); for ($i = 0; $i < 5000; $i++) { if ((microtime(true) - $start) > $maxTime) break; $upper = strtoupper($text); $lower = strtolower($text); $len = strlen($text); $pos = strpos($text, 'amet'); $replaced = str_replace('Lorem', 'Test', $text); $words = explode(' ', substr($text, 0, 500)); $trimmed = trim($text); $encoded = htmlspecialchars(substr($text, 0, 200), ENT_QUOTES, 'UTF-8'); } return round((microtime(true) - $start), 3); } /** * Benchmark CPU performance with binary operations * Tests bitwise operations (AND, OR, XOR, shifts) and modulo operations * * @return float Execution time in seconds */ function benchmark_cpu_random_binary_operations() { $start = microtime(true); $maxTime = 15.0; for ($i = 0; $i < 2000000; $i++) { if ((microtime(true) - $start) > $maxTime) break; $a = mt_rand(1, 1000000); $b = mt_rand(1, 1000000); $c = $a & $b; $d = $a | $b; $e = $a ^ $b; $f = $a << 2; $g = $b >> 2; $h = ($a + $b) % 1000000; $j = abs($a - $b); $k = (int)($a / max($b, 1)); } return round((microtime(true) - $start), 3); } // ============================================================================ // BENCHMARK FUNCTIONS - FILESYSTEM PERFORMANCE // ============================================================================ /** * Benchmark filesystem write performance * * Tests sequential file writes with metadata operations to evaluate disk I/O. * This benchmark measures: * - Raw write throughput * - fsync() performance (disk flush) * - Filesystem metadata operations (filesize, filemtime) * * IMPORTANT: Uses __DIR__ instead of sys_get_temp_dir() to ensure testing * on actual disk storage, not RAM-based tmpfs which would give unrealistic * results on some Linux systems. * * @return float Execution time in seconds (lower is better) */ function benchmark_filesystem_write() { $start = microtime(true); $maxTime = 20.0; // Test on actual disk, not tmpfs/ramdisk for realistic results $testFile = __DIR__ . DIRECTORY_SEPARATOR . 'bench_write_' . uniqid() . '.tmp'; $data = str_repeat('A', 10240); // 10KB per write try { $fp = fopen($testFile, 'wb'); if ($fp === false) { error_log('Filesystem Write benchmark failed: Cannot open file for writing'); return 0; } for ($i = 0; $i < 5000; $i++) { if ((microtime(true) - $start) > $maxTime) break; if (fwrite($fp, $data) === false) { error_log('Filesystem Write benchmark failed at iteration ' . $i . ': Cannot write to file'); fclose($fp); return 0; } // Force disk flush every 100 iterations to test true IOPS if ($i % 100 == 0) { if (function_exists('fsync')) { fsync($fp); } fflush($fp); // Fallback if fsync not available clearstatcache(); filesize($testFile); filemtime($testFile); } } fclose($fp); } catch (Exception $e) { error_log('Filesystem Write benchmark failed: ' . $e->getMessage()); return 0; } finally { if (file_exists($testFile)) { unlink($testFile); } } return round((microtime(true) - $start), 3); } /** * Benchmark filesystem copy and access performance * Tests file copying with content verification * * @return float Execution time in seconds */ function benchmark_filesystem_copy_access() { $start = microtime(true); $maxTime = 20.0; // Use __DIR__ to test actual disk (not tmpfs/ramdisk) $sourceFile = __DIR__ . DIRECTORY_SEPARATOR . 'bench_source_' . uniqid() . '.tmp'; $data = str_repeat('Test data for benchmark. This simulates a typical file. ', 500); try { if (file_put_contents($sourceFile, $data) === false) { error_log('Filesystem Copy benchmark failed: Cannot create source file'); return 0; } for ($i = 0; $i < 2000; $i++) { if ((microtime(true) - $start) > $maxTime) break; $destFile = __DIR__ . DIRECTORY_SEPARATOR . 'bench_dest_' . $i . '.tmp'; if (copy($sourceFile, $destFile)) { $content = file_get_contents($destFile); if ($content !== false && strlen($content) > 0) { if (file_exists($destFile)) { unlink($destFile); } } } else { error_log('Filesystem Copy benchmark failed at iteration ' . $i . ': Cannot copy file'); return 0; } } } catch (Exception $e) { error_log('Filesystem Copy benchmark failed: ' . $e->getMessage()); return 0; } finally { if (file_exists($sourceFile)) { unlink($sourceFile); } } return round((microtime(true) - $start), 3); } /** * Benchmark small file I/O operations * * Simulates real-world PHP application behavior with many small files: * - Session files (typical: 100-500 bytes) * - Cache entries (JSON data structures) * - Configuration files * * This test creates 100 small files and performs random read/write operations * to evaluate: * - Directory lookup performance * - Small file I/O speed * - JSON encode/decode overhead * - File locking behavior * * Random access pattern (vs sequential) tests filesystem performance under * realistic load where files are accessed unpredictably. * * @return float Execution time in seconds (lower is better) */ function benchmark_filesystem_small_io() { $start = microtime(true); $maxTime = 20.0; $baseDir = __DIR__ . DIRECTORY_SEPARATOR . 'bench_io_' . uniqid(); if (!mkdir($baseDir)) { return 0; } try { $files = []; // Pre-create 100 file paths (simulating cache/session files) for ($i = 0; $i < 100; $i++) { $files[$i] = $baseDir . DIRECTORY_SEPARATOR . 'file_' . $i . '.tmp'; } // Random Read/Write operations - forces directory lookups and seeks for ($i = 0; $i < 5000; $i++) { if ((microtime(true) - $start) > $maxTime) break; $fileIndex = mt_rand(0, 99); $file = $files[$fileIndex]; // Write random small JSON $data = json_encode([ 'id' => $i, 'val' => mt_rand(1, 1000), 'text' => str_repeat('x', mt_rand(10, 100)), 'ts' => microtime(true) ]); if (file_put_contents($file, $data) === false) { error_log('Filesystem Small I/O benchmark failed: Cannot write'); return 0; } // Read back immediately $content = file_get_contents($file); if ($content === false) { error_log('Filesystem Small I/O benchmark failed: Cannot read'); return 0; } // Verify content (CPU overhead) $decoded = json_decode($content, true); if (!$decoded || $decoded['id'] !== $i) { // Silent corruption check } } } catch (Exception $e) { error_log('Filesystem Small I/O benchmark failed: ' . $e->getMessage()); return 0; } finally { // Cleanup foreach ($files as $f) { if (file_exists($f)) unlink($f); } if (is_dir($baseDir)) rmdir($baseDir); } return round((microtime(true) - $start), 3); } // ============================================================================ // BENCHMARK FUNCTIONS - DATABASE PERFORMANCE // ============================================================================ /** * Benchmark database bulk insert performance using SQLite * Tests large batch inserts with indexes and transactions * Measures disk I/O performance and PHP's SQLite driver efficiency * * @return float Execution time in seconds, 0 if SQLite3 not available */ function benchmark_database_import_large() { if (!class_exists('SQLite3')) return 0; $start = microtime(true); $maxTime = 25.0; $dbFile = sys_get_temp_dir() . DIRECTORY_SEPARATOR . 'bench_db_' . uniqid() . '.sqlite'; $db = null; try { $db = new SQLite3($dbFile); $db->enableExceptions(true); $db->exec('CREATE TABLE test_table (id INTEGER PRIMARY KEY, name TEXT, email TEXT, value INTEGER, data TEXT, created_at TEXT)'); $db->exec('CREATE INDEX idx_name ON test_table(name)'); $db->exec('CREATE INDEX idx_value ON test_table(value)'); $stmt = $db->prepare('INSERT INTO test_table (name, email, value, data, created_at) VALUES (:name, :email, :value, :data, :created_at)'); $db->exec('BEGIN TRANSACTION'); for ($i = 0; $i < 5000; $i++) { if ((microtime(true) - $start) > $maxTime) break; $stmt->bindValue(':name', 'User_' . $i, SQLITE3_TEXT); $stmt->bindValue(':email', 'user' . $i . '@example.com', SQLITE3_TEXT); $stmt->bindValue(':value', mt_rand(1, 10000), SQLITE3_INTEGER); $stmt->bindValue(':data', str_repeat('x', 200), SQLITE3_TEXT); $stmt->bindValue(':created_at', date('Y-m-d H:i:s'), SQLITE3_TEXT); $stmt->execute(); $stmt->reset(); } $db->exec('COMMIT'); $stmt->close(); } catch (Exception $e) { error_log('Database Import benchmark failed: ' . $e->getMessage()); return 0; // Return 0 to indicate test failure } finally { if ($db) { $db->close(); } if (file_exists($dbFile)) { unlink($dbFile); } } return round((microtime(true) - $start), 3); } /** * Benchmark simple database queries using SQLite * Tests basic SELECT queries with WHERE clauses and indexes * Measures disk I/O performance and PHP's SQLite driver efficiency * * @return float Execution time in seconds, 0 if SQLite3 not available */ function benchmark_database_simple_queries() { if (!class_exists('SQLite3')) return 0; $start = microtime(true); $maxTime = 25.0; $dbFile = sys_get_temp_dir() . DIRECTORY_SEPARATOR . 'bench_db_' . uniqid() . '.sqlite'; $db = null; try { $db = new SQLite3($dbFile); $db->enableExceptions(true); $db->exec('CREATE TABLE users (id INTEGER PRIMARY KEY, username TEXT, email TEXT, status INTEGER)'); $db->exec('CREATE INDEX idx_username ON users(username)'); $insertStmt = $db->prepare('INSERT INTO users (username, email, status) VALUES (:username, :email, :status)'); $db->exec('BEGIN TRANSACTION'); for ($i = 0; $i < 500; $i++) { if ((microtime(true) - $start) > $maxTime) break; $insertStmt->bindValue(':username', 'user' . $i, SQLITE3_TEXT); $insertStmt->bindValue(':email', 'user' . $i . '@test.com', SQLITE3_TEXT); $insertStmt->bindValue(':status', mt_rand(0, 1), SQLITE3_INTEGER); $insertStmt->execute(); $insertStmt->reset(); } $db->exec('COMMIT'); $selectStmt = $db->prepare('SELECT * FROM users WHERE id = :id'); $selectByNameStmt = $db->prepare('SELECT * FROM users WHERE username = :username'); for ($i = 0; $i < 2000; $i++) { if ((microtime(true) - $start) > $maxTime) break; if ($i % 2 == 0) { $selectStmt->bindValue(':id', mt_rand(1, 500), SQLITE3_INTEGER); $result = $selectStmt->execute(); if ($result) { $row = $result->fetchArray(SQLITE3_ASSOC); $result->finalize(); } $selectStmt->reset(); } else { $selectByNameStmt->bindValue(':username', 'user' . mt_rand(1, 500), SQLITE3_TEXT); $result = $selectByNameStmt->execute(); if ($result) { $row = $result->fetchArray(SQLITE3_ASSOC); $result->finalize(); } $selectByNameStmt->reset(); } } $insertStmt->close(); $selectStmt->close(); $selectByNameStmt->close(); } catch (Exception $e) { error_log('Database Simple Queries benchmark failed: ' . $e->getMessage()); return 0; } finally { if ($db) { $db->close(); } if (file_exists($dbFile)) { unlink($dbFile); } } return round((microtime(true) - $start), 3); } /** * Benchmark complex database queries using SQLite * Tests GROUP BY, ORDER BY, and aggregation operations * Measures disk I/O performance and PHP's SQLite driver efficiency * * @return float Execution time in seconds, 0 if SQLite3 not available */ function benchmark_database_complex_queries() { if (!class_exists('SQLite3')) return 0; $start = microtime(true); $maxTime = 30.0; $dbFile = sys_get_temp_dir() . DIRECTORY_SEPARATOR . 'bench_db_' . uniqid() . '.sqlite'; $db = null; try { $db = new SQLite3($dbFile); $db->enableExceptions(true); // Create more realistic e-commerce schema $db->exec('CREATE TABLE customers (id INTEGER PRIMARY KEY, name TEXT, email TEXT, level INTEGER)'); $db->exec('CREATE TABLE products (id INTEGER PRIMARY KEY, name TEXT, price REAL, category TEXT)'); $db->exec('CREATE TABLE orders (id INTEGER PRIMARY KEY, customer_id INTEGER, total REAL, status TEXT, date TEXT)'); $db->exec('CREATE TABLE order_items (id INTEGER PRIMARY KEY, order_id INTEGER, product_id INTEGER, qty INTEGER, price REAL)'); $db->exec('CREATE INDEX idx_c_email ON customers(email)'); $db->exec('CREATE INDEX idx_p_cat ON products(category)'); $db->exec('CREATE INDEX idx_o_cust ON orders(customer_id)'); $db->exec('CREATE INDEX idx_oi_order ON order_items(order_id)'); // Seed data - heavier load $db->exec('BEGIN TRANSACTION'); // 1000 Customers $stmtC = $db->prepare('INSERT INTO customers (name, email, level) VALUES (:name, :email, :level)'); for ($i = 0; $i < 1000; $i++) { $stmtC->bindValue(':name', 'Customer ' . $i, SQLITE3_TEXT); $stmtC->bindValue(':email', 'cust' . $i . '@shop.com', SQLITE3_TEXT); $stmtC->bindValue(':level', mt_rand(1, 5), SQLITE3_INTEGER); $stmtC->execute(); $stmtC->reset(); } $stmtC->close(); // 500 Products $stmtP = $db->prepare('INSERT INTO products (name, price, category) VALUES (:name, :price, :cat)'); $cats = ['Electronics', 'Books', 'Home', 'Garden', 'Toys']; for ($i = 0; $i < 500; $i++) { $stmtP->bindValue(':name', 'Product ' . $i, SQLITE3_TEXT); $stmtP->bindValue(':price', mt_rand(10, 1000), SQLITE3_FLOAT); $stmtP->bindValue(':cat', $cats[array_rand($cats)], SQLITE3_TEXT); $stmtP->execute(); $stmtP->reset(); } $stmtP->close(); // 2000 Orders with Items $stmtO = $db->prepare('INSERT INTO orders (customer_id, total, status, date) VALUES (:cid, :total, :status, :date)'); $stmtOI = $db->prepare('INSERT INTO order_items (order_id, product_id, qty, price) VALUES (:oid, :pid, :qty, :price)'); for ($i = 0; $i < 2000; $i++) { if ((microtime(true) - $start) > $maxTime) break; $stmtO->bindValue(':cid', mt_rand(1, 1000), SQLITE3_INTEGER); $stmtO->bindValue(':total', mt_rand(50, 5000), SQLITE3_FLOAT); $stmtO->bindValue(':status', mt_rand(0,1) ? 'completed' : 'pending', SQLITE3_TEXT); $stmtO->bindValue(':date', date('Y-m-d'), SQLITE3_TEXT); $stmtO->execute(); $oid = $db->lastInsertRowID(); $stmtO->reset(); // Add 1-5 items per order $items = mt_rand(1, 5); for ($j = 0; $j < $items; $j++) { $stmtOI->bindValue(':oid', $oid, SQLITE3_INTEGER); $stmtOI->bindValue(':pid', mt_rand(1, 500), SQLITE3_INTEGER); $stmtOI->bindValue(':qty', mt_rand(1, 3), SQLITE3_INTEGER); $stmtOI->bindValue(':price', mt_rand(10, 100), SQLITE3_FLOAT); $stmtOI->execute(); $stmtOI->reset(); } } $db->exec('COMMIT'); $stmtO->close(); $stmtOI->close(); // Complex E-commerce Reporting Query (JOINs + Aggregation) // "Find top spending customers by category" $query = " SELECT c.name, p.category, SUM(oi.qty * oi.price) as total_spend FROM customers c JOIN orders o ON c.id = o.customer_id JOIN order_items oi ON o.id = oi.order_id JOIN products p ON oi.product_id = p.id WHERE o.status = 'completed' GROUP BY c.id, p.category ORDER BY total_spend DESC LIMIT 20 "; for ($i = 0; $i < 50; $i++) { // 50 Heavy queries if ((microtime(true) - $start) > $maxTime) break; $result = $db->query($query); if ($result) { while ($row = $result->fetchArray(SQLITE3_ASSOC)) {} // Fetch all $result->finalize(); } } } catch (Exception $e) { error_log('Database Complex Queries benchmark failed: ' . $e->getMessage()); return 0; } finally { if ($db) { $db->close(); } if (file_exists($dbFile)) { unlink($dbFile); } } return round((microtime(true) - $start), 3); } /** * Comprehensive standalone database performance benchmark (MySQL/MariaDB) * * This function performs an extensive evaluation of database performance by * testing multiple aspects with multi-pass sampling to ensure accuracy: * * TEST PHASES: * 1. Connection Latency (5 samples, outliers removed) * - Measures TCP connection + authentication time * - Scores: <2ms=10pts, <5ms=8pts, <10ms=5pts, <20ms=2pts * * 2. Write Throughput (5 runs of 10,000 inserts each) * - Tests bulk INSERT performance with transactions * - Includes UUID generation, mixed data types, and 500-char text * - Scores: >10k rows/s=15pts, >7.5k=12pts, >5k=9pts, >2.5k=5pts * * 3. Read Throughput (5 runs of 2,000 queries each) * - Tests indexed SELECT performance with WHERE clauses * - Scores: >8k q/s=15pts, >6k=12pts, >4k=9pts, >2k=5pts * * 4. CPU Performance (5 runs of 100 SHA2 operations) * - Tests cryptographic hashing with aggregation * - Measures database CPU capabilities * - Scores: <200ms=10pts, <500ms=8pts, <800ms=6pts, <1000ms=4pts * * SCORING: Total points out of 50, scaled to 0-10 score * * SECURITY: Creates temporary table with random name, cleaned up on exit * * @param string $host Database hostname or IP address * @param string $dbname Database name (must exist and be accessible) * @param string $user Database username with CREATE/INSERT/SELECT privileges * @param string $pass Database password * @param int $port Database port (default: 3306 for MySQL) * @return array ['success' => bool, 'score' => float, 'metrics' => array, 'error' => string] */ function benchmark_database_standalone($host, $dbname, $user, $pass, $port = 3306) { $metrics = []; $points = 0; $maxPoints = 50; // Total available points (scaled to 0-10 score) try { // Connection Test - Multi-pass sampling (5 runs) $connLatencies = []; for ($run = 0; $run < 5; $run++) { // Close and reconnect for each test if (isset($pdo)) unset($pdo); $connStart = microtime(true); $dsn = "mysql:host={$host};port={$port};dbname={$dbname};charset=utf8mb4"; $pdo = new PDO($dsn, $user, $pass, [ PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION, PDO::ATTR_DEFAULT_FETCH_MODE => PDO::FETCH_ASSOC ]); $connEnd = microtime(true); $connLatencies[] = ($connEnd - $connStart) * 1000; // Small delay between tests usleep(10000); // 10ms } // Remove outliers and average sort($connLatencies); array_shift($connLatencies); // Remove fastest (best) array_pop($connLatencies); // Remove slowest (worst) $connLatency = round(array_sum($connLatencies) / count($connLatencies), 2); $metrics['connection_latency'] = $connLatency; $metrics['connection_samples'] = 5; // Score connection latency: Punish anything over 5ms (localhost preference) if ($connLatency < 2) $points += 10; // Lightning fast elseif ($connLatency < 5) $points += 8; // Fast localhost elseif ($connLatency < 10) $points += 5; // OK localhost elseif ($connLatency < 20) $points += 2; // Slow connection else $points += 0; // Too slow // Generate random table name $tableName = 'bench_temp_' . bin2hex(random_bytes(8)); // Create temporary table $createTableSQL = "CREATE TABLE `{$tableName}` ( `id` INT AUTO_INCREMENT PRIMARY KEY, `uuid` VARCHAR(36) NOT NULL, `int_col` INT NOT NULL, `float_col` FLOAT NOT NULL, `text_col` TEXT NOT NULL, INDEX `idx_int_col` (`int_col`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4"; $pdo->exec($createTableSQL); // Write Test - Multi-pass sampling (5 runs of 10,000 inserts each) $writeThroughputs = []; for ($run = 0; $run < 5; $run++) { // Clear table before each run (except first) if ($run > 0) { $pdo->exec("TRUNCATE TABLE `{$tableName}`"); } $writeStart = microtime(true); $pdo->beginTransaction(); $stmt = $pdo->prepare("INSERT INTO `{$tableName}` (uuid, int_col, float_col, text_col) VALUES (?, ?, ?, ?)"); for ($i = 0; $i < 10000; $i++) { $uuid = sprintf('%04x%04x-%04x-%04x-%04x-%04x%04x%04x', mt_rand(0, 0xffff), mt_rand(0, 0xffff), mt_rand(0, 0xffff), mt_rand(0, 0x0fff) | 0x4000, mt_rand(0, 0x3fff) | 0x8000, mt_rand(0, 0xffff), mt_rand(0, 0xffff), mt_rand(0, 0xffff) ); $intVal = mt_rand(1, 10000); $floatVal = mt_rand(1, 10000) / 100.0; // Larger text payload: 500 characters of random data $textVal = str_repeat(substr(md5(mt_rand()), 0, 10), 50) . '_' . $i; $stmt->execute([$uuid, $intVal, $floatVal, $textVal]); } $pdo->commit(); $writeEnd = microtime(true); $writeTime = $writeEnd - $writeStart; $writeThroughputs[] = 10000 / $writeTime; // Small delay between runs usleep(50000); // 50ms } // Remove outliers and average sort($writeThroughputs); array_shift($writeThroughputs); // Remove fastest array_pop($writeThroughputs); // Remove slowest $writeThroughput = round(array_sum($writeThroughputs) / count($writeThroughputs), 2); $metrics['write_throughput'] = $writeThroughput; $metrics['write_samples'] = 5; // Score write throughput: Require NVMe speeds for top marks if ($writeThroughput > 10000) $points += 15; // NVMe beast elseif ($writeThroughput > 7500) $points += 12; // Fast SSD elseif ($writeThroughput > 5000) $points += 9; // Good SSD elseif ($writeThroughput > 2500) $points += 5; // Average else $points += 1; // Slow // Read Test - Multi-pass sampling (5 runs of 2,000 queries each) $readThroughputs = []; for ($run = 0; $run < 5; $run++) { $readStart = microtime(true); $selectStmt = $pdo->prepare("SELECT * FROM `{$tableName}` WHERE int_col = ?"); for ($i = 0; $i < 2000; $i++) { $randInt = mt_rand(1, 10000); $selectStmt->execute([$randInt]); $selectStmt->fetchAll(); } $readEnd = microtime(true); $readTime = $readEnd - $readStart; $readThroughputs[] = 2000 / $readTime; // Small delay between runs usleep(30000); // 30ms } // Remove outliers and average sort($readThroughputs); array_shift($readThroughputs); // Remove fastest array_pop($readThroughputs); // Remove slowest $readThroughput = round(array_sum($readThroughputs) / count($readThroughputs), 2); $metrics['read_throughput'] = $readThroughput; $metrics['read_samples'] = 5; // Score read throughput: Strict performance requirements if ($readThroughput > 8000) $points += 15; // Elite performance elseif ($readThroughput > 6000) $points += 12; // Excellent elseif ($readThroughput > 4000) $points += 9; // Very good elseif ($readThroughput > 2000) $points += 5; // Average else $points += 1; // Slow // CPU Test - Multi-pass sampling (5 runs of 100 SHA2 operations each) $cpuTimes = []; for ($run = 0; $run < 5; $run++) { $cpuStart = microtime(true); $cryptoStmt = $pdo->prepare("SELECT COUNT(*) as cnt, SUM(CAST(CONV(SUBSTRING(SHA2(text_col, 256), 1, 8), 16, 10) AS UNSIGNED)) as hash_sum, AVG(LENGTH(text_col)) as avg_len FROM `{$tableName}`"); for ($i = 0; $i < 100; $i++) { $cryptoStmt->execute(); $cryptoStmt->fetch(); } $cpuEnd = microtime(true); $cpuTimes[] = ($cpuEnd - $cpuStart) * 1000; // Small delay between runs usleep(30000); // 30ms } // Remove outliers and average sort($cpuTimes); array_shift($cpuTimes); // Remove fastest array_pop($cpuTimes); // Remove slowest $cpuTime = round(array_sum($cpuTimes) / count($cpuTimes), 2); $metrics['cpu_time'] = $cpuTime; $metrics['cpu_samples'] = 5; // Score CPU time: Steeper curve for cryptographic operations if ($cpuTime < 200) $points += 10; // Elite CPU elseif ($cpuTime < 500) $points += 8; // Very good elseif ($cpuTime < 800) $points += 6; // Good elseif ($cpuTime < 1000) $points += 4; // Average else $points += 1; // Slow // Calculate final score (0-10) $score = round(($points / $maxPoints) * 10, 2); return [ 'success' => true, 'score' => $score, 'metrics' => $metrics ]; } catch (PDOException $e) { return [ 'success' => false, 'error' => $e->getMessage(), 'score' => 0, 'metrics' => [] ]; } catch (Exception $e) { return [ 'success' => false, 'error' => $e->getMessage(), 'score' => 0, 'metrics' => [] ]; } finally { if (isset($pdo) && isset($tableName)) { try { @$pdo->exec("DROP TABLE IF EXISTS `{$tableName}`"); } catch (Exception $e) { // Ignore cleanup errors } } } } // ============================================================================ // BENCHMARK FUNCTIONS - CACHE PERFORMANCE // ============================================================================ /** * Establish connection to object cache service (Redis or Memcached) * * This function attempts to detect and connect to available caching services * in the following order: * * 1. Redis (port 6379) - Preferred for performance and features * 2. Memcached (port 11211) - Fallback option * * Connection attempts use short timeouts (1 second) to avoid hanging * if services are not available. All connection errors are suppressed * with @ operator as cache unavailability is an expected condition. * * @return array|null Returns ['type' => 'redis'|'memcached', 'conn' => object] * or null if no cache service is available */ function get_cache_connection() { // Try Redis first (fastest and most feature-rich) if (class_exists('Redis')) { try { $redis = new Redis(); // Connect with 1 second timeout to localhost Redis if (@$redis->connect('127.0.0.1', 6379, 1)) { // Verify connection is alive @$redis->ping(); return ['type' => 'redis', 'conn' => $redis]; } } catch (Exception $e) { // Redis extension exists but connection failed - this is normal } } // Fallback to Memcached if (class_exists('Memcached')) { try { $memcached = new Memcached(); $memcached->addServer('127.0.0.1', 11211); // Test connection by getting server stats $stats = @$memcached->getStats(); if ($stats && count($stats) > 0) { return ['type' => 'memcached', 'conn' => $memcached]; } } catch (Exception $e) { // Memcached extension exists but connection failed - this is normal } } // No cache service available return null; } /** * Clean up benchmark test cache keys from Redis/Memcached * * After benchmark tests complete, this function removes all temporary keys * created during cache performance testing. Keys follow the pattern * 'phpprobe_key_*' to avoid conflicts with actual cached data. * * IMPORTANT: For Redis, this uses the SCAN command (non-blocking) instead * of KEYS (blocking) to prevent performance impact on production servers. * If SCAN is unavailable, cleanup is skipped rather than risk blocking * the Redis instance. * * @return void */ function cleanup_cache_keys() { $cache_info = get_cache_connection(); if (!$cache_info) return; $cache = $cache_info['conn']; $type = $cache_info['type']; if ($type === 'redis') { // Use SCAN (non-blocking) to iterate through keys // SCAN is production-safe as it doesn't block the Redis server try { $iterator = null; // Iterate through matching keys using SCAN cursor while ($keys = $cache->scan($iterator, 'phpprobe_key_*', 100)) { if ($keys && is_array($keys)) { foreach ($keys as $key) { $cache->del($key); } } // Iterator becomes 0 when complete if ($iterator === 0) break; } } catch (Exception $e) { // If SCAN fails, skip cleanup rather than using blocking KEYS // This is safer for production Redis servers with large keyspaces error_log('Redis cache cleanup skipped: SCAN not available or failed - ' . $e->getMessage()); } } // Note: Memcached keys auto-expire after 60 seconds, so cleanup isn't critical } /** * Check if object cache (Redis/Memcached) is available * * @return string|int Cache type ('redis' or 'memcached') or 0 if unavailable */ function benchmark_object_cache_enabled() { $cache = get_cache_connection(); if (!$cache) return 0; return $cache['type']; } /** * Benchmark object cache write performance * Tests cache write operations with data serialization * * @return float Execution time in seconds, 0 if cache unavailable */ function benchmark_object_cache_write() { $start = microtime(true); $maxTime = 15.0; $cache_info = get_cache_connection(); if (!$cache_info) return 0; $cache = $cache_info['conn']; $type = $cache_info['type']; try { for ($i = 0; $i < 5000; $i++) { if ((microtime(true) - $start) > $maxTime) break; $key = 'phpprobe_key_' . $i; $value = ['data' => str_repeat('x', 100), 'timestamp' => time()]; if ($type === 'redis') { $cache->setex($key, 60, serialize($value)); } else { $cache->set($key, $value, 60); } } } catch (Exception $e) { error_log('Cache Write benchmark failed: ' . $e->getMessage()); return 0; } finally { cleanup_cache_keys(); } return round((microtime(true) - $start), 3); } /** * Benchmark object cache read performance * Tests cache read operations with data unserialization * * @return float Execution time in seconds, 0 if cache unavailable */ function benchmark_object_cache_read() { $start = microtime(true); $maxTime = 15.0; $cache_info = get_cache_connection(); if (!$cache_info) return 0; $cache = $cache_info['conn']; $type = $cache_info['type']; try { for ($i = 0; $i < 5000; $i++) { $key = 'phpprobe_key_' . $i; $value = ['data' => str_repeat('x', 100), 'timestamp' => time()]; if ($type === 'redis') { $cache->setex($key, 60, serialize($value)); } else { $cache->set($key, $value, 60); } } $readStart = microtime(true); for ($i = 0; $i < 5000; $i++) { if ((microtime(true) - $start) > $maxTime) break; $key = 'phpprobe_key_' . mt_rand(0, 4999); if ($type === 'redis') { $value = $cache->get($key); if ($value) unserialize($value); } else { $value = $cache->get($key); } } return round((microtime(true) - $readStart), 3); } catch (Exception $e) { error_log('Cache Read benchmark failed: ' . $e->getMessage()); return 0; } finally { cleanup_cache_keys(); } } /** * Benchmark mixed cache operations (70% read, 30% write) * Simulates realistic cache usage patterns * * @return float Execution time in seconds, 0 if cache unavailable */ function benchmark_object_cache_mixed() { $start = microtime(true); $maxTime = 15.0; $cache_info = get_cache_connection(); if (!$cache_info) return 0; $cache = $cache_info['conn']; $type = $cache_info['type']; try { for ($i = 0; $i < 3000; $i++) { if ((microtime(true) - $start) > $maxTime) break; if (mt_rand(1, 100) <= 70 && $i > 100) { $key = 'phpprobe_key_' . mt_rand(0, $i - 1); if ($type === 'redis') { $value = $cache->get($key); if ($value) unserialize($value); } else { $value = $cache->get($key); } } else { $key = 'phpprobe_key_' . $i; $value = ['data' => str_repeat('x', 100), 'timestamp' => time()]; if ($type === 'redis') { $cache->setex($key, 60, serialize($value)); } else { $cache->set($key, $value, 60); } } } } catch (Exception $e) { error_log('Cache Mixed Operations benchmark failed: ' . $e->getMessage()); return 0; } finally { cleanup_cache_keys(); } return round((microtime(true) - $start), 3); } /** * Check if OPcache is enabled * * @return int 1 if enabled, 0 if disabled or unavailable */ function benchmark_opcache_enabled() { if (!function_exists('opcache_get_status')) { return 0; } $status = @opcache_get_status(false); if (!$status || !isset($status['opcache_enabled'])) { return 0; } return $status['opcache_enabled'] ? 1 : 0; } /** * Benchmark OPcache performance * Tests PHP file inclusion speed with OPcache enabled * * @return float Execution time in seconds, 0 if OPcache unavailable */ function benchmark_opcache_performance() { if (!function_exists('opcache_get_status')) { return 0; } $start = microtime(true); $maxTime = 3.0; $testFile = sys_get_temp_dir() . DIRECTORY_SEPARATOR . 'opcache_test_' . uniqid() . '.php'; $testCode = ' 0 && $i % 20 == 0) { if ((microtime(true) - $start) > $maxTime) { break; } } include $testFile; $iterations++; } return round((microtime(true) - $start), 3); } catch (Exception $e) { error_log('OPcache Performance benchmark failed: ' . $e->getMessage()); return 0; } finally { if (file_exists($testFile)) { unlink($testFile); } } } function get_opcache_info() { if (!function_exists('opcache_get_status')) { return [ 'enabled' => false, 'status' => 'Not Available' ]; } $status = @opcache_get_status(false); if (!$status) { return [ 'enabled' => false, 'status' => 'Disabled' ]; } $config = @opcache_get_configuration(); return [ 'enabled' => $status['opcache_enabled'] ?? false, 'status' => ($status['opcache_enabled'] ?? false) ? 'Enabled' : 'Disabled', 'memory_used' => isset($status['memory_usage']['used_memory']) ? formatsize($status['memory_usage']['used_memory']) : 'N/A', 'memory_free' => isset($status['memory_usage']['free_memory']) ? formatsize($status['memory_usage']['free_memory']) : 'N/A', 'memory_wasted' => isset($status['memory_usage']['wasted_memory']) ? formatsize($status['memory_usage']['wasted_memory']) : 'N/A', 'hit_rate' => isset($status['opcache_statistics']['opcache_hit_rate']) ? round($status['opcache_statistics']['opcache_hit_rate'], 2) . '%' : 'N/A', 'cached_scripts' => $status['opcache_statistics']['num_cached_scripts'] ?? 0, 'cached_keys' => $status['opcache_statistics']['num_cached_keys'] ?? 0, 'max_cached_keys' => $status['opcache_statistics']['max_cached_keys'] ?? 0, 'hits' => $status['opcache_statistics']['hits'] ?? 0, 'misses' => $status['opcache_statistics']['misses'] ?? 0, 'jit_enabled' => isset($config['directives']['opcache.jit']) && $config['directives']['opcache.jit'] !== 'disable' && $config['directives']['opcache.jit'] !== '0', 'jit_buffer_size' => isset($config['directives']['opcache.jit_buffer_size']) ? $config['directives']['opcache.jit_buffer_size'] : 'N/A' ]; } // ============================================================================ // BENCHMARK FUNCTIONS - NETWORK PERFORMANCE // ============================================================================ /** * Benchmark network speed and connectivity * Tests DNS resolution, TCP connections, and file downloads * * @return float Execution time in seconds */ function benchmark_network_speed() { $start = microtime(true); $maxTime = 15.0; $dnsTargets = ['google.com', 'cloudflare.com', 'github.com']; foreach ($dnsTargets as $domain) { if ((microtime(true) - $start) > $maxTime) break; gethostbyname($domain); } $latencyTargets = [ 'tcp://1.1.1.1:80', 'tcp://8.8.8.8:53', 'ssl://www.cloudflare.com:443' ]; foreach ($latencyTargets as $target) { if ((microtime(true) - $start) > $maxTime) break; $fp = stream_socket_client($target, $errno, $errstr, 2); if ($fp) fclose($fp); } $downloadSuccess = false; $testUrls = [ 'https://speed.cloudflare.com/__down?bytes=1000000', 'https://gra.proof.ovh.net/files/1Mb.dat', 'https://syd.proof.ovh.net/files/1Mb.dat', 'https://sgp.proof.ovh.net/files/1Mb.dat', 'https://bhs.proof.ovh.net/files/1Mb.dat', 'https://fra.proof.ovh.net/files/1Mb.dat', ]; $context = stream_context_create([ 'http' => [ 'timeout' => 5, 'user_agent' => 'PHP-Benchmark/2.1' ], 'ssl' => [ 'verify_peer' => true, 'verify_peer_name' => true ] ]); foreach ($testUrls as $url) { if ((microtime(true) - $start) > $maxTime) break; $downloadStart = microtime(true); try { $data = file_get_contents($url, false, $context); $downloadTime = microtime(true) - $downloadStart; if ($data !== false && strlen($data) > 500000) { $downloadSuccess = true; break; } } catch (Exception $e) { error_log('Network benchmark failed for ' . $url . ': ' . $e->getMessage()); // Continue to next URL } } if (!$downloadSuccess && function_exists('curl_init')) { foreach ($testUrls as $url) { if ((microtime(true) - $start) > $maxTime) break; $ch = curl_init($url); curl_setopt_array($ch, [ CURLOPT_RETURNTRANSFER => true, CURLOPT_TIMEOUT => 5, CURLOPT_CONNECTTIMEOUT => 3, CURLOPT_SSL_VERIFYPEER => true, CURLOPT_SSL_VERIFYHOST => 2, CURLOPT_USERAGENT => 'PHP-Benchmark/2.1' ]); $downloadStart = microtime(true); $data = curl_exec($ch); $downloadTime = microtime(true) - $downloadStart; $httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE); curl_close($ch); if ($data !== false && strlen($data) > 500000 && $httpCode == 200) { $downloadSuccess = true; break; } } } if (!$downloadSuccess) { return 0; // Fail if no download succeeded } return round((microtime(true) - $start), 3); } /** * Benchmark network latency to multiple global endpoints * * Measures network connectivity quality by testing: * 1. DNS resolution speed for multiple domains * 2. HTTP connection establishment (via cURL CONNECT_TIME) * * Tests three globally distributed services: * - google.com - Global presence with edge locations * - cloudflare.com - Global CDN with fast response * - github.com - Developer-focused, globally available * * Lower latency indicates: * - Good network routing to internet backbones * - Fast DNS server response * - Low packet loss and jitter * * Important for applications making external API calls, webhooks, * or fetching remote resources. * * @return float Average latency in milliseconds (lower is better), 0 if unable to measure */ function benchmark_network_latency() { $start = microtime(true); $maxTime = 3.0; $timeout = 1.5; $latencies = []; $dnsDomains = ['google.com', 'cloudflare.com', 'github.com']; foreach ($dnsDomains as $domain) { if ((microtime(true) - $start) > $maxTime) break; $dnsStart = microtime(true); $ip = gethostbyname($domain); if ($ip !== $domain) { $latencies[] = (microtime(true) - $dnsStart) * 1000; } if ((microtime(true) - $dnsStart) > $timeout) break; } if (function_exists('curl_init')) { $testUrl = 'https://www.google.com'; $curlStart = microtime(true); $ch = curl_init(); curl_setopt_array($ch, [ CURLOPT_URL => $testUrl, CURLOPT_RETURNTRANSFER => true, CURLOPT_TIMEOUT => $timeout, CURLOPT_CONNECTTIMEOUT => $timeout, CURLOPT_NOBODY => true, CURLOPT_SSL_VERIFYPEER => true, CURLOPT_SSL_VERIFYHOST => 2 ]); curl_exec($ch); $connectTime = curl_getinfo($ch, CURLINFO_CONNECT_TIME); curl_close($ch); if ($connectTime > 0 && $connectTime < $timeout) { $latencies[] = $connectTime * 1000; } } if (empty($latencies)) { return 0; } return round(array_sum($latencies) / count($latencies), 2); } /** * Benchmark server concurrency handling (stress test) * * This function is called MULTIPLE TIMES IN PARALLEL (15 simultaneous requests) * by JavaScript code to simulate real-world concurrent load. This tests: * * WEB SERVER CAPABILITIES: * - Apache/Nginx worker pool size and configuration * - PHP-FPM process manager settings (pm.max_children) * - Request queuing behavior under load * - Session locking impact (mitigated by session_write_close) * * WHAT IT MEASURES: * - Average response time under concurrent load * - System stability with multiple simultaneous PHP processes * - CPU + I/O performance when resources are contested * * REAL-WORLD RELEVANCE: * Production websites rarely serve one request at a time. This test * reveals how your server handles traffic spikes and concurrent users. * * Each request performs realistic work (CPU math + file I/O) rather than * just sleeping, to properly stress the system. * * @return float Execution time in seconds for this single request */ /** * Worker function for concurrency test * Performs the actual CPU and I/O work for a single request */ function benchmark_concurrency_worker() { $start = microtime(true); // Simulate realistic work: CPU + I/O (not just usleep) $result = 0; // CPU work: Math operations to load processor // Reduced iterations (20000) to test concurrency behavior, not raw CPU for ($i = 0; $i < 20000; $i++) { $result += sqrt($i) * sin($i); } // Small I/O work (test real disk, not ramdisk) $testFile = __DIR__ . DIRECTORY_SEPARATOR . 'bench_concurrency_' . uniqid() . '.tmp'; $ioSuccess = false; try { $data = json_encode(['iteration' => $result, 'time' => microtime(true)]); if (file_put_contents($testFile, $data) !== false) { if (file_get_contents($testFile) !== false) { $ioSuccess = true; } } } catch (Exception $e) { error_log('Concurrency benchmark I/O failed: ' . $e->getMessage()); } finally { if (file_exists($testFile)) { unlink($testFile); } } if (!$ioSuccess) return 0; // Fail if I/O failed return round((microtime(true) - $start), 4); } /** * Get the full URL of the current script */ function get_self_url() { $protocol = (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] === 'on') ? "https" : "http"; $host = $_SERVER['HTTP_HOST']; $uri = $_SERVER['REQUEST_URI']; // Remove query string to get clean script path $uri = strtok($uri, '?'); return $protocol . "://" . $host . $uri; } /** * Manager function for concurrency test * Uses curl_multi to fire parallel requests to the worker endpoint */ function benchmark_concurrency() { // Check if curl is available if (!function_exists('curl_multi_init')) { // Fallback to single worker execution (not concurrent, but better than error) return benchmark_concurrency_worker(); } $count = 15; // Number of parallel requests $mh = curl_multi_init(); $handles = []; $url = get_self_url() . '?act=worker&type=concurrency'; // Create handles for ($i = 0; $i < $count; $i++) { $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_TIMEOUT, 10); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false); // Add a random parameter to prevent caching curl_setopt($ch, CURLOPT_URL, $url . '&r=' . mt_rand()); curl_multi_add_handle($mh, $ch); $handles[] = $ch; } // Execute handles $running = null; $start = microtime(true); do { curl_multi_exec($mh, $running); curl_multi_select($mh); } while ($running > 0); $totalTime = microtime(true) - $start; // Collect results and close handles $successCount = 0; foreach ($handles as $ch) { $info = curl_getinfo($ch); if ($info['http_code'] == 200) { $successCount++; } curl_multi_remove_handle($mh, $ch); curl_close($ch); } curl_multi_close($mh); // If fewer than half succeeded, consider it a failure if ($successCount < ($count / 2)) { return 0; } // Return total batch time (not average) to properly measure parallelism // A well-parallelized server completes 15 requests in ~0.2s (parallel) // A serial/throttled server takes 3.0s+ (queued execution) return round($totalTime, 4); } // ============================================================================ // BENCHMARK FUNCTIONS - BASIC CPU OPERATIONS // ============================================================================ /** * Benchmark integer arithmetic operations * Tests basic CPU computational speed with integer math * * @return float Execution time in seconds */ function benchmark_cpu_int() { $start = microtime(true); $maxTime = 15.0; $result = 0; for ($i = 0; $i < 20000000; $i++) { if ((microtime(true) - $start) > $maxTime) break; $x = $i + $i; $y = $i * 2; $z = $x - $y + $i; $result += $z; } return round((microtime(true) - $start), 4); } /** * Benchmark floating-point arithmetic operations * Tests CPU performance with mathematical functions (sqrt, pow, log, sin, cos) * * @return float Execution time in seconds */ function benchmark_cpu_float() { $start = microtime(true); $maxTime = 15.0; $pi = pi(); $e = exp(1); $result = 0.0; for ($i = 0; $i < 5000000; $i++) { if ((microtime(true) - $start) > $maxTime) break; $x = ($i % 10000) + 1; $result += sqrt($pi * $x); $result += pow($x, 0.5); $result += log($x + 1) * $e; $result += abs(sin($x * 0.1) * cos($x * 0.1)); } return round((microtime(true) - $start), 4); } /** * Benchmark file I/O operations * Tests sequential file reading with pointer rewinding * * @return float Execution time in seconds */ function benchmark_io() { $start = microtime(true); $maxTime = 15.0; try { $fp = fopen(__FILE__, 'r'); if ($fp === false) { error_log('File I/O benchmark failed: Cannot open file for reading'); return 0; } for ($i = 0; $i < 10000; $i++) { if ((microtime(true) - $start) > $maxTime) break; fread($fp, 1024); rewind($fp); } fclose($fp); } catch (Exception $e) { error_log('File I/O benchmark failed: ' . $e->getMessage()); return 0; } return round((microtime(true) - $start), 4); } /** * Benchmark string manipulation operations * Tests case conversion, substring, search, replace, and trimming * * @return float Execution time in seconds */ function benchmark_string() { $start = microtime(true); $maxTime = 15.0; $str = 'The quick brown fox jumps over the lazy dog. This is a more realistic test string with multiple sentences.'; $longStr = str_repeat($str, 50); for ($i = 0; $i < 500000; $i++) { if ((microtime(true) - $start) > $maxTime) break; $upper = strtoupper($str); $lower = strtolower($str); $len = strlen($longStr); $sub = substr($longStr, 0, 100); $replaced = str_replace('fox', 'cat', $str); $pos = strpos($longStr, 'dog'); $trimmed = trim($str); } return round((microtime(true) - $start), 4); } /** * Benchmark array operations * Tests reversing, summing, filtering, mapping, merging, and sorting * * @return float Execution time in seconds */ function benchmark_array() { $start = microtime(true); $maxTime = 15.0; $baseArr = range(1, 500); // Calibrated for realistic micro-benchmark duration (~0.5-0.7s on modern hardware) for ($i = 0; $i < 25000; $i++) { if ((microtime(true) - $start) > $maxTime) break; $arr = $baseArr; $reversed = array_reverse($arr); $sum = array_sum($arr); $filtered = array_filter($arr, function($v) { return $v > 250; }); $mapped = array_map(function($v) { return $v * 2; }, array_slice($arr, 0, 100)); $merged = array_merge($arr, $filtered); sort($arr); } return round((microtime(true) - $start), 4); } /** * Benchmark hashing operations * Tests MD5, SHA1, SHA256, SHA512, and CRC32 algorithms * * @return float Execution time in seconds */ function benchmark_hash() { $start = microtime(true); $maxTime = 15.0; $str = 'benchmark test string for hashing with more data to make it realistic'; for ($i = 0; $i < 200000; $i++) { if ((microtime(true) - $start) > $maxTime) break; $data = $str . $i; $md5 = md5($data); $sha1 = sha1($data); if (function_exists('hash')) { $sha256 = hash('sha256', $data); $sha512 = hash('sha512', $data); } if (function_exists('crc32')) { $crc = crc32($data); } } return round((microtime(true) - $start), 4); } /** * Benchmark JSON encoding and decoding operations * Tests serialization/deserialization of complex nested data structures * * @return float Execution time in seconds */ function benchmark_json() { $start = microtime(true); $maxTime = 15.0; $data = [ 'name' => 'Test User', 'email' => 'test@example.com', 'age' => 30, 'active' => true, 'roles' => ['admin', 'user', 'moderator'], 'metadata' => [ 'created' => '2024-01-01', 'updated' => '2024-01-15', 'preferences' => ['theme' => 'dark', 'lang' => 'en'] ], 'items' => range(1, 50) ]; for ($i = 0; $i < 200000; $i++) { if ((microtime(true) - $start) > $maxTime) break; $json = json_encode($data); $decoded = json_decode($json, true); if (is_array($decoded) && isset($decoded['name'])) { $name = $decoded['name']; } } return round((microtime(true) - $start), 4); } /** * Check database extension availability * Tests for MySQLi, PDO, SQLite3, PostgreSQL, MongoDB, Redis, and Memcached * * @return array Database support status */ function benchmark_database_support() { $results = []; if (class_exists('mysqli')) { $results['MySQL (mysqli)'] = '✓ Available'; } else { $results['MySQL (mysqli)'] = '✗ Not Available'; } if (class_exists('PDO')) { $drivers = PDO::getAvailableDrivers(); $results['PDO'] = '✓ Available (' . implode(', ', $drivers) . ')'; } else { $results['PDO'] = '✗ Not Available'; } if (class_exists('SQLite3')) { $ver = SQLite3::version(); $results['SQLite3'] = '✓ v' . $ver['versionString']; } else { $results['SQLite3'] = '✗ Not Available'; } $results['PostgreSQL'] = function_exists('pg_connect') ? '✓ Available' : '✗ Not Available'; $results['MongoDB'] = class_exists('MongoDB\Driver\Manager') ? '✓ Available' : '✗ Not Available'; $results['Redis'] = class_exists('Redis') ? '✓ Available' : '✗ Not Available'; $results['Memcached'] = class_exists('Memcached') ? '✓ Available' : '✗ Not Available'; return $results; } /** * Benchmark regular expression operations * Tests email, URL, phone number, and HTML pattern matching * * @return float Execution time in seconds */ function benchmark_regex() { $start = microtime(true); $maxTime = 15.0; $emailPattern = '/^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$/'; $urlPattern = '/^https?:\/\/(www\.)?[-a-zA-Z0-9@:%._\+~#=]{1,256}\.[a-zA-Z0-9()]{1,6}\b([-a-zA-Z0-9()@:%_\+.~#?&\/\/=]*)$/'; $phonePattern = '/^[\+]?[(]?[0-9]{3}[)]?[-\s\.]?[0-9]{3}[-\s\.]?[0-9]{4,6}$/'; $testEmails = []; $testUrls = []; for ($j = 0; $j < 100; $j++) { $testEmails[] = "user{$j}@example{$j}.com"; $testUrls[] = "https://www.example{$j}.com/path/to/page?id={$j}"; } for ($i = 0; $i < 50000; $i++) { if ((microtime(true) - $start) > $maxTime) break; foreach ($testEmails as $email) { preg_match($emailPattern, $email); } foreach (array_slice($testUrls, 0, 10) as $url) { preg_match($urlPattern, $url); } preg_match($phonePattern, '+1-234-567-8900'); $html = '
Content

Paragraph

'; preg_match_all('/<([a-z]+)([^<]+)*(?:>(.*)<\/\1>|\s+\/>)/', $html, $matches); } return round((microtime(true) - $start), 3); } /** * Benchmark large JSON processing operations * Tests encoding/decoding of large nested data structures with filtering * * @return float Execution time in seconds */ function benchmark_large_json() { $start = microtime(true); $maxTime = 15.0; $largeData = []; for ($i = 0; $i < 500; $i++) { $largeData[] = [ 'id' => $i, 'name' => 'Product ' . $i, 'description' => 'This is a detailed description for product ' . $i . ' with lots of text.', 'price' => rand(10, 1000) / 10, 'stock' => rand(0, 100), 'categories' => ['Category A', 'Category B', 'Category C'], 'attributes' => [ 'color' => 'Blue', 'size' => 'Medium', 'weight' => rand(1, 50), 'dimensions' => ['length' => rand(1, 100), 'width' => rand(1, 100), 'height' => rand(1, 100)] ], 'reviews' => [ ['user' => 'User ' . $i, 'rating' => rand(1, 5), 'comment' => 'Great product!'], ['user' => 'User ' . ($i + 1), 'rating' => rand(1, 5), 'comment' => 'Good value.'] ] ]; } $jsonString = json_encode($largeData); $jsonSize = strlen($jsonString); for ($i = 0; $i < 5000; $i++) { if ((microtime(true) - $start) > $maxTime) break; $decoded = json_decode($jsonString, true); if (is_array($decoded) && count($decoded) > 0) { $firstItem = $decoded[0]; $filtered = array_filter($decoded, function($item) { return isset($item['price']) && $item['price'] > 50; }); } $reEncoded = json_encode(array_slice($decoded, 0, 10)); } return round((microtime(true) - $start), 3); } /** * Benchmark XML parsing operations * Tests SimpleXML parsing and element iteration * * @return float Execution time in seconds */ function benchmark_xml_parsing() { $start = microtime(true); $maxTime = 15.0; $xmlContent = ''; for ($i = 0; $i < 200; $i++) { $xmlContent .= ''; $xmlContent .= 'Item Title ' . $i . ''; $xmlContent .= 'This is a description for item ' . $i . ''; $xmlContent .= '' . (rand(10, 1000) / 10) . ''; $xmlContent .= 'Category ' . ($i % 10) . ''; $xmlContent .= 'BlueM'; $xmlContent .= ''; } $xmlContent .= ''; for ($i = 0; $i < 3000; $i++) { if ((microtime(true) - $start) > $maxTime) break; $xml = @simplexml_load_string($xmlContent); if ($xml) { foreach ($xml->item as $item) { $id = (string)$item['id']; $title = (string)$item->title; $price = (float)$item->price; if ($price > 50) { $filtered = $item; } } } } return round((microtime(true) - $start), 3); } /** * Benchmark password hashing operations * Tests bcrypt password hashing and verification * * @return float Execution time in seconds */ function benchmark_password_hashing() { $start = microtime(true); $maxTime = 15.0; $passwords = []; for ($j = 0; $j < 20; $j++) { $passwords[] = 'password' . $j . rand(1000, 9999); } $hashes = []; $count = 0; for ($i = 0; $i < 500; $i++) { if ((microtime(true) - $start) > $maxTime) break; $password = $passwords[$i % 20]; $hash = password_hash($password, PASSWORD_BCRYPT, ['cost' => 10]); $hashes[] = $hash; if (count($hashes) > 0) { password_verify($password, $hashes[count($hashes) - 1]); } $count++; } return round((microtime(true) - $start), 3); } /** * Benchmark date/time operations * Tests DateTime creation, formatting, timezone conversion, and calculations * * @return float Execution time in seconds */ function benchmark_datetime_operations() { $start = microtime(true); $maxTime = 15.0; $timezones = ['America/New_York', 'Europe/London', 'Asia/Tokyo', 'Australia/Sydney']; for ($i = 0; $i < 100000; $i++) { if ((microtime(true) - $start) > $maxTime) break; $date1 = new DateTime('2024-01-01 10:00:00', new DateTimeZone('UTC')); $date2 = new DateTime('2024-12-31 23:59:59', new DateTimeZone('UTC')); $formatted1 = $date1->format('Y-m-d H:i:s'); $formatted2 = $date2->format('l, F j, Y'); $diff = $date1->diff($date2); $days = $diff->days; $date1->modify('+1 month'); $date1->modify('+15 days'); $tz = $timezones[$i % 4]; $date1->setTimezone(new DateTimeZone($tz)); $timestamp = $date1->getTimestamp(); $fromTimestamp = (new DateTime())->setTimestamp($timestamp); } return round((microtime(true) - $start), 3); } /** * Benchmark CSV processing operations * Tests CSV file creation, reading, and data filtering * * @return float Execution time in seconds */ function benchmark_csv_processing() { $start = microtime(true); $maxTime = 15.0; $csvFile = sys_get_temp_dir() . DIRECTORY_SEPARATOR . 'bench_csv_' . uniqid() . '.csv'; try { $fp = fopen($csvFile, 'w'); if (!$fp) return 0; fputcsv($fp, ['ID', 'Name', 'Email', 'Phone', 'Address', 'City', 'Country', 'ZIP', 'Total']); for ($j = 0; $j < 1000; $j++) { fputcsv($fp, [ $j, 'Customer ' . $j, 'customer' . $j . '@example.com', '+1-234-567-' . str_pad($j, 4, '0', STR_PAD_LEFT), $j . ' Main Street', 'City ' . ($j % 50), 'Country ' . ($j % 10), str_pad($j, 5, '0', STR_PAD_LEFT), rand(100, 10000) / 10 ]); } fclose($fp); for ($i = 0; $i < 100; $i++) { if ((microtime(true) - $start) > $maxTime) break; $fp = fopen($csvFile, 'r'); if (!$fp) break; $headers = fgetcsv($fp); $data = []; while (($row = fgetcsv($fp)) !== false) { $record = array_combine($headers, $row); if (isset($record['Total']) && (float)$record['Total'] > 500) { $data[] = $record; } } fclose($fp); } } finally { @unlink($csvFile); } return round((microtime(true) - $start), 3); } /** * Benchmark session file operations * Simulates session file creation, reading, and cleanup * * @return float Execution time in seconds */ function benchmark_session_operations() { $start = microtime(true); $maxTime = 15.0; $sessionDir = sys_get_temp_dir() . DIRECTORY_SEPARATOR . 'bench_sessions_' . uniqid(); @mkdir($sessionDir); try { for ($i = 0; $i < 10000; $i++) { if ((microtime(true) - $start) > $maxTime) break; $sessionId = 'sess_' . md5('session' . $i); $sessionFile = $sessionDir . DIRECTORY_SEPARATOR . $sessionId; $sessionData = serialize([ 'user_id' => $i, 'username' => 'user' . $i, 'email' => 'user' . $i . '@example.com', 'login_time' => time(), 'preferences' => ['theme' => 'dark', 'lang' => 'en'], 'cart' => ['item1', 'item2', 'item3'] ]); file_put_contents($sessionFile, $sessionData); $content = file_get_contents($sessionFile); $data = unserialize($content); if ($i % 100 == 0) { @unlink($sessionFile); } } } finally { $files = glob($sessionDir . DIRECTORY_SEPARATOR . '*'); if ($files) { foreach ($files as $file) { @unlink($file); } } @rmdir($sessionDir); } return round((microtime(true) - $start), 3); } /** * Benchmark image processing operations using GD library * Tests image creation, drawing, and resizing operations * * @return float Execution time in seconds, 0 if GD not available */ function benchmark_image_operations() { $start = microtime(true); $maxTime = 15.0; if (!function_exists('imagecreate')) { return 0; } for ($i = 0; $i < 200; $i++) { // Reduced iterations, increased complexity if ((microtime(true) - $start) > $maxTime) break; $width = 1200; $height = 900; $img = imagecreatetruecolor($width, $height); if (!$img) continue; // Fill background $bg = imagecolorallocate($img, 240, 240, 240); imagefill($img, 0, 0, $bg); // Draw random complex shapes for ($j = 0; $j < 50; $j++) { $color = imagecolorallocatealpha($img, mt_rand(0, 255), mt_rand(0, 255), mt_rand(0, 255), mt_rand(0, 50)); imagefilledellipse($img, mt_rand(0, $width), mt_rand(0, $height), mt_rand(10, 200), mt_rand(10, 200), $color); } // Add text with scaling $text_color = imagecolorallocate($img, 0, 0, 0); imagestring($img, 5, 50, 50, 'Heavy Image Benchmark ' . $i, $text_color); // 1. Resizing (Resampling) - CPU intensive $newWidth = 600; $newHeight = 450; $resized = imagecreatetruecolor($newWidth, $newHeight); if ($resized) { imagecopyresampled($resized, $img, 0, 0, 0, 0, $newWidth, $newHeight, $width, $height); // 2. Apply Filter (Grayscale) - CPU intensive if (function_exists('imagefilter')) { imagefilter($resized, IMG_FILTER_GRAYSCALE); imagefilter($resized, IMG_FILTER_CONTRAST, -5); } imagedestroy($resized); } imagedestroy($img); } return round((microtime(true) - $start), 3); } // ============================================================================ // PHP CONFIGURATION FUNCTIONS // ============================================================================ /** * Get detailed PHP extension information with versions * * @return array Extension names with their versions */ function get_php_extensions_detailed() { $extensions = get_loaded_extensions(); $detailed = []; foreach ($extensions as $ext) { $version = phpversion($ext); $detailed[$ext] = $version ?: 'loaded'; } return $detailed; } /** * Check availability of important PHP functions by category * * @return array Function availability grouped by category */ function check_important_functions() { $functions = [ 'File Operations' => ['fopen', 'fread', 'fwrite', 'file_get_contents', 'file_put_contents', 'unlink', 'mkdir'], 'Network' => ['curl_init', 'fsockopen', 'gethostbyname', 'dns_get_record'], 'Compression' => ['gzencode', 'gzdecode', 'gzcompress', 'gzuncompress', 'bz2compress', 'bz2decompress'], 'Cryptography' => ['md5', 'sha1', 'hash', 'openssl_encrypt', 'openssl_decrypt', 'password_hash'], 'Image' => ['imagecreate', 'imagecreatefromjpeg', 'imagejpeg', 'imagepng', 'imagegif', 'imagewebp'], 'Mail' => ['mail', 'imap_open'], 'Session' => ['session_start', 'session_destroy', 'session_id'], 'Execution' => ['exec', 'system', 'shell_exec', 'passthru', 'proc_open'], 'System' => ['sys_getloadavg', 'disk_free_space', 'disk_total_space', 'getenv', 'putenv'] ]; $results = []; foreach ($functions as $category => $funcs) { $results[$category] = []; foreach ($funcs as $func) { $results[$category][$func] = function_exists($func); } } return $results; } /** * Get current timezone information * * @return array Timezone details including offset, abbreviation, and DST status */ function get_timezone_info() { return [ 'current' => date_default_timezone_get(), 'offset' => date('P'), 'abbreviation' => date('T'), 'dst' => date('I') ? 'Yes' : 'No' ]; } /** * Get server software versions * Detects Apache, PHP, cURL, GD, ImageMagick, libxml, and ICU versions * * @return array Software versions */ function get_server_software_versions() { $versions = []; if (function_exists('apache_get_version')) { $versions['Apache'] = apache_get_version(); } $versions['PHP'] = PHP_VERSION; $versions['PHP SAPI'] = php_sapi_name(); $versions['Zend Engine'] = zend_version(); if (defined('OPENSSL_VERSION_TEXT')) { $versions['OpenSSL'] = OPENSSL_VERSION_TEXT; } if (function_exists('curl_version')) { $curl = curl_version(); $versions['cURL'] = $curl['version']; $versions['cURL SSL'] = $curl['ssl_version']; } if (function_exists('gd_info')) { $gd = gd_info(); $versions['GD'] = $gd['GD Version']; } if (class_exists('Imagick')) { $imagick = new Imagick(); $version = $imagick->getVersion(); $versions['ImageMagick'] = $version['versionString']; } if (defined('LIBXML_DOTTED_VERSION')) { $versions['libxml'] = LIBXML_DOTTED_VERSION; } if (defined('INTL_ICU_VERSION')) { $versions['ICU'] = INTL_ICU_VERSION; } return $versions; } /** * Get PHP configuration limits * * @return array PHP limits including memory, execution time, upload sizes, etc. */ function get_php_limits() { return [ 'memory_limit' => ini_get('memory_limit'), 'post_max_size' => ini_get('post_max_size'), 'upload_max_filesize' => ini_get('upload_max_filesize'), 'max_execution_time' => ini_get('max_execution_time') . 's', 'max_input_time' => ini_get('max_input_time') . 's', 'max_input_vars' => ini_get('max_input_vars'), 'default_socket_timeout' => ini_get('default_socket_timeout') . 's', 'max_file_uploads' => ini_get('max_file_uploads'), ]; } /** * Get HTTP connection information * * @return array Connection details including protocol, method, HTTPS status, user agent */ function get_connection_info() { return [ 'Protocol' => $_SERVER['SERVER_PROTOCOL'] ?? 'N/A', 'Request Method' => $_SERVER['REQUEST_METHOD'] ?? 'N/A', 'HTTPS' => (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] === 'on') ? 'Yes' : 'No', 'User Agent' => $_SERVER['HTTP_USER_AGENT'] ?? 'N/A', 'Accept Encoding' => $_SERVER['HTTP_ACCEPT_ENCODING'] ?? 'N/A', 'Accept Language' => $_SERVER['HTTP_ACCEPT_LANGUAGE'] ?? 'N/A', ]; } // ============================================================================ // DATA COLLECTION & INITIALIZATION // ============================================================================ $hosting_env = detect_hosting_environment(); $server_info = [ 'server_id' => php_uname(), 'server_os' => PHP_OS . ' Kernel version: ' . php_uname('r'), 'server_language' => $_SERVER['HTTP_ACCEPT_LANGUAGE'] ?? 'N/A', 'server_hostname' => php_uname('n'), 'server_name' => $_SERVER['SERVER_NAME'] ?? 'N/A', 'server_addr' => $_SERVER['SERVER_ADDR'] ?? @gethostbyname($_SERVER['SERVER_NAME']), 'client_ip' => $_SERVER['REMOTE_ADDR'] ?? 'N/A', 'server_software' => $_SERVER['SERVER_SOFTWARE'] ?? 'N/A', 'server_port' => $_SERVER['SERVER_PORT'] ?? 'N/A', 'server_admin' => $_SERVER['SERVER_ADMIN'] ?? 'N/A', 'root_path' => $_SERVER['DOCUMENT_ROOT'] ?? dirname(__FILE__), 'prober_path' => __FILE__, 'current_time' => date('Y-m-d H:i:s'), 'uptime' => get_uptime(), 'hosting_type' => $hosting_env['type'] == 'shared' ? 'Shared Hosting' : 'Hosting', ]; $cpu_info = get_cpu_info(); $cpu_usage = get_cpu_usage(); $memory_info = get_memory_info(); $load_avg = get_load_average(); $network_info = get_network_info(); $network_total_rx = 0; $network_total_tx = 0; foreach ($network_info as $iface => $ifaceData) { $network_total_rx += $ifaceData['rx']; $network_total_tx += $ifaceData['tx']; } $network_interfaces = !empty($network_info) ? implode(', ', array_keys($network_info)) : 'N/A'; $timezone_info = get_timezone_info(); $versions = get_server_software_versions(); $php_limits = get_php_limits(); $connection_info = get_connection_info(); $opcache_info = get_opcache_info(); $disk_total = @disk_total_space(".") ? @disk_total_space(".") : 0; $disk_free = @disk_free_space(".") ? @disk_free_space(".") : 0; $disk_used = $disk_total - $disk_free; $disk_percent = $disk_total > 0 ? round(($disk_used / $disk_total) * 100, 2) : 0; $mem_format = []; if ($memory_info['total'] >= 1024) { $mem_format['total'] = round($memory_info['total'] / 1024, 3) . ' G'; $mem_format['used'] = round($memory_info['used'] / 1024, 3) . ' G'; $mem_format['free'] = round($memory_info['free'] / 1024, 3) . ' G'; $mem_format['cached'] = round($memory_info['cached'] / 1024, 3) . ' G'; $mem_format['buffers'] = round($memory_info['buffers'] / 1024, 3) . ' G'; $mem_format['real_used'] = round($memory_info['real_used'] / 1024, 3) . ' G'; $mem_format['real_free'] = round($memory_info['real_free'] / 1024, 3) . ' G'; $mem_format['swap_total'] = round($memory_info['swap_total'] / 1024, 3) . ' G'; $mem_format['swap_used'] = round($memory_info['swap_used'] / 1024, 3) . ' G'; $mem_format['swap_free'] = round($memory_info['swap_free'] / 1024, 3) . ' G'; } else { $mem_format['total'] = $memory_info['total'] . ' M'; $mem_format['used'] = $memory_info['used'] . ' M'; $mem_format['free'] = $memory_info['free'] . ' M'; $mem_format['cached'] = $memory_info['cached'] . ' M'; $mem_format['buffers'] = $memory_info['buffers'] . ' M'; $mem_format['real_used'] = $memory_info['real_used'] . ' M'; $mem_format['real_free'] = $memory_info['real_free'] . ' M'; $mem_format['swap_total'] = $memory_info['swap_total'] . ' M'; $mem_format['swap_used'] = $memory_info['swap_used'] . ' M'; $mem_format['swap_free'] = $memory_info['swap_free'] . ' M'; } // ============================================================================ // API ENDPOINTS // ============================================================================ if (isset($_GET['act'])) { // Handle worker request for concurrency test if ($_GET['act'] === 'worker' && isset($_GET['type']) && $_GET['type'] === 'concurrency') { $time = benchmark_concurrency_worker(); header('Content-Type: application/json'); echo json_encode(['time' => $time]); exit; } $action = sanitize_input($_GET['act'], 'alnum'); /** * Display PHP information */ if ($action === 'phpinfo') { phpinfo(); exit; } /** * Handle TCP ping/latency test requests */ if ($action === 'ping' && isset($_GET['target'])) { header('Content-Type: application/json'); $target = trim($_GET['target']); $port = isset($_GET['port']) ? (int)$_GET['port'] : 80; $count = isset($_GET['count']) ? min((int)$_GET['count'], 10) : 4; if ($port < 1 || $port > 65535) { echo json_encode(['error' => 'Invalid port number']); exit; } if (empty($target) || strlen($target) > 255) { echo json_encode(['error' => 'Invalid target']); exit; } if (!preg_match('/^[a-zA-Z0-9\.\-]+$/', $target)) { echo json_encode(['error' => 'Invalid target format. Use hostname or IP only.']); exit; } $results = []; $successful = 0; $failed = 0; $totalTime = 0; $minTime = PHP_FLOAT_MAX; $maxTime = 0; for ($i = 0; $i < $count; $i++) { $start = microtime(true); $errno = 0; $errstr = ''; $fp = @stream_socket_client( "tcp://{$target}:{$port}", $errno, $errstr, 3, STREAM_CLIENT_CONNECT ); $time = (microtime(true) - $start) * 1000; if ($fp) { fclose($fp); $results[] = [ 'success' => true, 'time' => round($time, 2), 'seq' => $i + 1 ]; $successful++; $totalTime += $time; $minTime = min($minTime, $time); $maxTime = max($maxTime, $time); } else { $results[] = [ 'success' => false, 'error' => $errstr ?: 'Connection timeout', 'seq' => $i + 1 ]; $failed++; } if ($i < $count - 1) { usleep(200000); } } $response = [ 'target' => $target, 'port' => $port, 'results' => $results, 'summary' => [ 'sent' => $count, 'received' => $successful, 'lost' => $failed, 'loss_percent' => round(($failed / $count) * 100, 1) ] ]; if ($successful > 0) { $response['summary']['min'] = round($minTime, 2); $response['summary']['max'] = round($maxTime, 2); $response['summary']['avg'] = round($totalTime / $successful, 2); } echo json_encode($response); exit; } /** * Helper: Run a specific benchmark test and calculate score * * @param string $type Benchmark type * @return array Result and score */ function run_benchmark_test($type, $scoring_mode = null) { global $SCORING_THRESHOLDS, $DEFAULT_SCORING_MODE; // Determine scoring mode if ($scoring_mode === null) { $scoring_mode = isset($_GET['scoring']) ? $_GET['scoring'] : $DEFAULT_SCORING_MODE; } // Validate scoring mode if (!isset($SCORING_THRESHOLDS[$scoring_mode])) { $scoring_mode = $DEFAULT_SCORING_MODE; } $result = 0; $score = 0; try { // Get the appropriate thresholds $lookup_type = $type; if ($type === 'network_latency') $lookup_type = 'network_latency_ms'; $thresholds = isset($SCORING_THRESHOLDS[$scoring_mode][$lookup_type]) ? $SCORING_THRESHOLDS[$scoring_mode][$lookup_type] : [1.0, 2.0, 4.0, 8.0]; // Fallback defaults // Determine if we should use aggressive scoring (modern mode) $aggressive = ($scoring_mode === 'modern'); // Define tests that benefit from sampling (fast execution, prone to jitter) $sampleable_tests = [ 'cpu_int', 'cpu_float', 'cpu_text', 'cpu_binary', 'string', 'array', 'hash', 'json', 'io', 'fs_write', 'fs_copy', 'fs_small', 'db_import', 'db_simple', 'db_complex', 'opcache_performance', 'cache_write', 'cache_read', 'cache_mixed', 'regex', 'large_json', 'xml_parsing', 'password_hashing', 'datetime', 'csv', 'session', 'image' ]; // Determine sample count // Modern mode: 3 samples for accuracy // Light mode: 1 sample for speed // Network/Concurrency: Always 1 sample to avoid timeouts/excessive load $sample_count = 1; if ($scoring_mode === 'modern' && in_array($type, $sampleable_tests)) { $sample_count = 3; } $total_result = 0; $valid_samples = 0; for ($i = 0; $i < $sample_count; $i++) { $current_result = 0; switch ($type) { case 'cpu_int': $current_result = benchmark_cpu_int(); break; case 'cpu_float': $current_result = benchmark_cpu_float(); break; case 'io': $current_result = benchmark_io(); break; case 'string': $current_result = benchmark_string(); break; case 'array': $current_result = benchmark_array(); break; case 'hash': $current_result = benchmark_hash(); break; case 'json': $current_result = benchmark_json(); break; case 'cpu_text': $current_result = benchmark_cpu_operations_large_text(); break; case 'cpu_binary': $current_result = benchmark_cpu_random_binary_operations(); break; case 'fs_write': $current_result = benchmark_filesystem_write(); break; case 'fs_copy': $current_result = benchmark_filesystem_copy_access(); break; case 'fs_small': $current_result = benchmark_filesystem_small_io(); break; case 'db_import': $current_result = benchmark_database_import_large(); break; case 'db_simple': $current_result = benchmark_database_simple_queries(); break; case 'db_complex': $current_result = benchmark_database_complex_queries(); break; case 'cache_enabled': $current_result = benchmark_object_cache_enabled(); // Non-numeric result, break loop $total_result = $current_result; $valid_samples = 1; $i = $sample_count; break; case 'opcache_enabled': $current_result = benchmark_opcache_enabled(); // Boolean result, break loop $total_result = $current_result; $valid_samples = 1; $i = $sample_count; break; case 'opcache_performance': $current_result = benchmark_opcache_performance(); break; case 'cache_write': $current_result = benchmark_object_cache_write(); break; case 'cache_read': $current_result = benchmark_object_cache_read(); break; case 'cache_mixed': $current_result = benchmark_object_cache_mixed(); break; case 'network': $current_result = benchmark_network_speed(); break; case 'network_latency': $current_result = benchmark_network_latency(); break; case 'concurrency': $current_result = benchmark_concurrency(); break; case 'regex': $current_result = benchmark_regex(); break; case 'large_json': $current_result = benchmark_large_json(); break; case 'xml_parsing': $current_result = benchmark_xml_parsing(); break; case 'password_hashing': $current_result = benchmark_password_hashing(); break; case 'datetime': $current_result = benchmark_datetime_operations(); break; case 'csv': $current_result = benchmark_csv_processing(); break; case 'session': $current_result = benchmark_session_operations(); break; case 'image': $current_result = benchmark_image_operations(); break; } // Accumulate numeric results if (is_numeric($current_result)) { $total_result += $current_result; $valid_samples++; } else if ($i === 0) { // For non-numeric first result (like 'redis'), keep it $total_result = $current_result; $valid_samples = 1; break; // Don't sample non-numeric tests } // Small pause between samples to let system settle if ($sample_count > 1) usleep(50000); } // Calculate average if ($valid_samples > 0 && is_numeric($total_result)) { $result = round($total_result / $valid_samples, 4); } else { $result = is_numeric($total_result) ? round($total_result, 4) : $total_result; } // Calculate score based on average result // Handle special non-numeric cases first if ($type === 'cache_enabled') { $score = ($result === 'redis' || $result === 'memcached') ? 10 : 0; } elseif ($type === 'opcache_enabled') { $score = $result ? 10 : 0; } else { // Standard numeric scoring $score = $result > 0 ? calculate_score($result, $thresholds[0], $thresholds[1], $thresholds[2], $thresholds[3], $aggressive) : 0; } return ['result' => $result, 'score' => $score, 'mode' => $scoring_mode]; } catch (Throwable $e) { return ['error' => 'Benchmark failed: ' . $e->getMessage(), 'result' => 0, 'score' => 0]; } } /** * Handle single benchmark test request */ if ($action === 'benchmark' && isset($_GET['type'])) { // Release the session lock so parallel requests can run concurrently // Without this, PHP's default session locking causes all 15 requests to queue up session_write_close(); @set_time_limit(30); if (ob_get_level()) ob_end_clean(); header('Content-Type: application/json'); $type = sanitize_input($_GET['type'], 'alnum'); $result = run_benchmark_test($type); echo json_encode($result); exit; } /** * Handle custom database benchmark request */ if ($action === 'db_custom_bench' && $_SERVER['REQUEST_METHOD'] === 'POST') { @set_time_limit(120); // Extended timeout for multi-pass sampling (5 runs per test) if (ob_get_level()) ob_end_clean(); header('Content-Type: application/json'); // Retrieve and sanitize POST parameters $host = isset($_POST['db_host']) ? trim($_POST['db_host']) : ''; $dbname = isset($_POST['db_name']) ? trim($_POST['db_name']) : ''; $user = isset($_POST['db_user']) ? trim($_POST['db_user']) : ''; $pass = isset($_POST['db_pass']) ? $_POST['db_pass'] : ''; $port = isset($_POST['db_port']) ? (int)$_POST['db_port'] : 3306; // Validate required fields if (empty($host) || empty($dbname) || empty($user)) { echo json_encode([ 'success' => false, 'error' => 'Host, Database Name, and Username are required fields.' ]); exit; } // Validate port if ($port < 1 || $port > 65535) { echo json_encode([ 'success' => false, 'error' => 'Invalid port number. Must be between 1 and 65535.' ]); exit; } // Run the benchmark $result = benchmark_database_standalone($host, $dbname, $user, $pass, $port); echo json_encode($result); exit; } } /** * Handle AJAX update requests for real-time data */ if (isset($_GET['ajax']) && $_GET['ajax'] === 'update') { @set_time_limit(5); // Quick timeout for update requests header('Content-Type: application/json'); $memory = get_memory_info(); $cpu = get_cpu_usage(); $load = get_load_average(); $disk_t = @disk_total_space("."); $disk_f = @disk_free_space("."); $disk_u = $disk_t - $disk_f; $disk_p = $disk_t > 0 ? round(($disk_u / $disk_t) * 100, 2) : 0; $net = get_network_info(); echo json_encode([ 'memory' => $memory, 'cpu' => $cpu, 'load' => $load, 'disk_used' => round($disk_u / (1024*1024*1024), 3), 'disk_free' => round($disk_f / (1024*1024*1024), 3), 'disk_percent' => $disk_p, 'network' => $net, 'time' => date('Y-m-d H:i:s'), 'uptime' => get_uptime() ]); exit; } // ============================================================================ // HTML OUTPUT // ============================================================================ ?> Hosting Benchmark

Hosting Benchmark Dashboard

v1.0.1
🚪 Logout
🔒
SECURITY REMINDER: Evaluation Tool Only
This is a diagnostic/benchmarking tool with intentional error reporting. Delete this file after completing your server evaluation. Do not leave it accessible on a production website. For security: change default credentials, restrict access via .htaccess, or remove the file entirely when done.
Shared Hosting Detected
Some system information (CPU model, system memory, server uptime) may not be available due to hosting restrictions. This is normal for shared hosting environments.
Server Health Snapshot
CPU Usage
%
User: % Sys: % Idle: %
80 ? '#ef4444' : ($cpu_percent > 60 ? '#f59e0b' : '#8b5cf6'); ?>
%
Cores
Memory Usage
%
Used: MB Free: MB
%
Total: MB
Disk Space
%
Used: Free:
%
Total:
System Load
0.7) { $load_status = 'warning'; $load_icon = 'exclamation-triangle'; } if ($load_per_core > 1.0) { $load_status = 'danger'; $load_icon = 'exclamation-circle'; } ?> per core
Uptime:
Network Traffic
In: Out:
Interface(s)
Server Parameters
Server ID
Server OS Web Server
Access Level Limited system access'; } else { echo 'Full access'; } ?> Restrictions ' . implode(', ', $hosting_env['restrictions']) . ''; } else { echo 'None detected'; } ?>
Server Language Server Port
Server Hostname Root Path
Server Admin Prober Path
Server Real time Data
Current Time Server Uptime
CPU Model [Core] ' . htmlspecialchars($cpu_info['model']) . ' (System info not available on shared hosting)'; } else { echo htmlspecialchars($cpu_info['model']); if ($cpu_info['mhz']) echo ' | frequency:' . $cpu_info['mhz'] . 'GHz'; if ($cpu_info['cache']) echo ' | Secondary cache:' . $cpu_info['cache'] . ' KB'; if ($cpu_info['bogomips']) echo ' | Bogomips:' . $cpu_info['bogomips']; if ($cpu_info['cores'] > 1) echo ' ×' . $cpu_info['cores']; } ?>
CPU Usage %us, %sy, %ni, %id, %wa, %irq, %softirq
Space Usage Total Space G, Used G, Free G, Rate %
Memory Usage ⚠ System memory not accessible on shared hosting
Showing PHP Script Memory Limit instead:
PHP Memory Limit: , Total Memory: , Used , Free , Rate %
Cache Memory , Rate % | Buffers
Real Memory Used , Real Memory Free , Rate %
0): ?> SWAP: , Used , Free , Rate %
System Load
$data): ?>
Network
: In: Real time: 0B/s Out: Real time: 0B/s
Performance Benchmarking
Custom Latency Test (TCP Ping)
About This Test
Test network latency to any server or IP address using TCP connection time. This uses TCP connections (not ICMP ping) which works without special privileges. Results may differ slightly from traditional ping but are still accurate for latency measurement.
Quick Presets:
🏆 Comprehensive Hosting Performance Benchmark

This comprehensive benchmark evaluates your hosting environment across multiple dimensions including CPU performance, memory operations, filesystem I/O, database performance, caching capabilities, and network operations. Perfect for comparing shared hosting providers and identifying performance bottlenecks.

Note: Tests are designed for shared hosting environments and use only standard PHP functions. No external dependencies required. Each test runs safely within typical hosting limits.

Scoring Mode:
Modern: Reflects 2025 hosting standards with NVMe and modern CPUs
MySQL / MariaDB Performance Test
About This Test
Test the performance of your MySQL or MariaDB database server. This benchmark will create a temporary table, test write/read throughput, run aggregation queries, and clean up after itself. No permanent changes are made to your database.

Database Connection

🗄️

Results will appear here after running the test

PHP Configuration & Extensions
🚀 OPcache Status (Critical for PHP Performance)
Status ✓ ' . htmlspecialchars($opcache_info['status']) . ''; if ($opcache_info['jit_enabled'] ?? false) { echo ' (JIT Enabled)'; } } else { echo '✗ ' . htmlspecialchars($opcache_info['status']) . ''; } ?> Hit Rate
Memory Used Memory Free
Cached Scripts Cache Keys /
Cache Hits Cache Misses
JIT Buffer Size
⚠️ Warning: OPcache is not enabled. Enabling OPcache can improve PHP performance by 3-10x!
Add opcache.enable=1 to your php.ini file.
$value): ?>
PHP Limits & Configuration
Timezone Information
Current Timezone UTC Offset
Timezone Abbreviation Daylight Saving Time
$status): ?>
Database Support
$functions): ?> $available): ?>
Important Functions Availability
✓' : ''; ?>
PHP Extensions ()
$ver) { echo htmlspecialchars($ext); if ($ver !== 'loaded') echo ' (' . htmlspecialchars($ver) . ')'; echo ' '; $count++; if ($count % 10 == 0) echo '
'; } ?>
PHP Parameters
PHP information PHPINFO PHP Version
Run PHP Memory Limit
POST Max Size Upload Max Filesize
Max Execution Time Second Socket TimeOut Second
Display Errors Allow URL fopen
Disable Functions None'; ?>
System & Server Information
$version): ?>
Software Versions
$value): ?>
Connection Information
Hosting Benchmark v1.0.0 Dashboard | Processed in seconds | memory usage