Capture some key stats for performance detail output.

This commit is contained in:
martinlanghoff
2005-04-02 13:31:38 +00:00
parent 66c5bee694
commit 51e565d1ad
+27
View File
@@ -69,6 +69,33 @@ global $THEME;
die;
}
/// Time to start counting
$PERF = new Object;
if(!empty($CFG->perfdebug)) {
if (function_exists('microtime')) {
$PERF->starttime = microtime();
}
if (function_exists('memory_get_usage')) {
$PERF->startmemory = memory_get_usage();
}
if (function_exists('posix_times')) {
$PERF->startposixtimes = posix_times();
}
// Grab the load average for the last minute
// /proc will only work under some linux configurations
// while uptime is there under MacOSX/Darwin and other unices
if (is_readable('/proc/loadavg') && $loadavg = @file('/proc/loadavg')) {
list($PERF->server_load) = explode(' ', $loadavg[0]);
unset($loadavg);
} else if ( is_executable('/usr/bin/uptime') && $loadavg = `/usr/bin/uptime` ) {
if (preg_match('/load averages?: (\d+:\d+)/', $loadavg, $matches)) {
$PERF->server_load = $matches[1];
} else {
trigger_error('Could not parse uptime output!');
}
}
}
/// If there are any errors in the standard libraries we want to know!
error_reporting(E_ALL);