Created
April 24, 2025 01:01
-
-
Save defmans7/f812d738e4270c181687accd1bf20d59 to your computer and use it in GitHub Desktop.
Check if Opcache is enabled and show some stats
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
header('Content-Type: text/plain'); | |
echo "PHP Version: " . phpversion() . "\n\n"; | |
echo "OPCache Enabled: " . (opcache_get_status() ? "Yes" : "No") . "\n\n"; | |
if (opcache_get_status()) { | |
$status = opcache_get_status(); | |
$config = opcache_get_configuration(); | |
echo "Memory Usage: " . round($status['memory_usage']['used_memory'] / (1024*1024), 2) . "MB / " . | |
($config['directives']['opcache.memory_consumption']) . "MB\n"; | |
echo "Hit Rate: " . $status['opcache_statistics']['opcache_hit_rate'] . "%\n"; | |
echo "Cached Scripts: " . $status['opcache_statistics']['num_cached_scripts'] . " / " . | |
$config['directives']['opcache.max_accelerated_files'] . "\n"; | |
if (isset($status['jit'])) { | |
echo "\nJIT Enabled: Yes\n"; | |
echo "JIT Buffer Used: " . round($status['jit']['buffer_used'] / (1024*1024), 2) . "MB / " . | |
round($status['jit']['buffer_size'] / (1024*1024), 2) . "MB\n"; | |
} else { | |
echo "\nJIT Enabled: No\n"; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment