Skip to content

Commit

Permalink
Capture some key stats for performance detail output.
Browse files Browse the repository at this point in the history
  • Loading branch information
martinlanghoff committed Apr 2, 2005
1 parent 66c5bee commit 51e565d
Showing 1 changed file with 27 additions and 0 deletions.
27 changes: 27 additions & 0 deletions lib/setup.php
Expand Up @@ -69,6 +69,33 @@
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);
Expand Down

0 comments on commit 51e565d

Please sign in to comment.