mirror of
https://gh.wpcy.net/https://github.com/szepeviktor/wordpress-website-lifecycle.git
synced 2026-04-24 05:09:10 +08:00
24 lines
605 B
PHP
24 lines
605 B
PHP
<?php
|
|
|
|
/*
|
|
* Plugin Name: Log memory usage (DBG)
|
|
* Plugin URI: https://github.com/szepeviktor/wordpress-website-lifecycle
|
|
*/
|
|
|
|
add_action(
|
|
'shutdown',
|
|
static function () {
|
|
$peakUsage = memory_get_peak_usage(true);
|
|
// Report above 20 MB.
|
|
if ($peakUsage < 20 * 1024 * 1024) {
|
|
return;
|
|
}
|
|
$uri = 'CLI';
|
|
if (isset($_SERVER['REQUEST_URI'])) {
|
|
$uri = wp_json_encode($_SERVER['REQUEST_URI'], JSON_UNESCAPED_SLASHES);
|
|
}
|
|
error_log(sprintf('Peak memory usage = %d bytes, %s', $peakUsage, $uri));
|
|
},
|
|
-1,
|
|
0
|
|
);
|