# Please don't move this line to includes/Defines.php. This line essentially # defines a valid entry point. If you put it in includes/Defines.php, then # any script that includes it becomes an entry point, thereby defeating # its purpose. define('MEDIAWIKI', true); # Full path to working directory. # Makes it possible to for example to have effective exclude path in apc. # __DIR__ breaks symlinked includes, but realpath() returns false # if we don't have permissions on parent directories. $IP = getenv('MW_INSTALL_PATH'); if ($IP === false) { $IP = realpath('.') ?: dirname(__DIR__); } # Load the profiler require_once "{$IP}/includes/profiler/Profiler.php"; $wgRUstart = wfGetRusage() ?: array(); # Start the autoloader, so that extensions can derive classes from core files require_once "{$IP}/includes/AutoLoader.php"; # Load up some global defines. require_once "{$IP}/includes/Defines.php"; # Start the profiler $wgProfiler = array(); if (file_exists("{$IP}/StartProfiler.php")) { require "{$IP}/StartProfiler.php"; } wfProfileIn('WebStart.php-conf'); # Load default settings require_once "{$IP}/includes/DefaultSettings.php"; # Load composer's autoloader if present if (is_readable("{$IP}/vendor/autoload.php")) { require_once "{$IP}/vendor/autoload.php";
/** * @return int|null Max memory RSS in kilobytes */ private function getMaxRssKb() { $info = wfGetRusage() ?: array(); // see http://linux.die.net/man/2/getrusage return isset($info['ru_maxrss']) ? (int) $info['ru_maxrss'] : null; }
private static function getTimes($clock = null) { $ret = array(); if (!$clock || $clock === 'wall') { $ret['wall'] = microtime(true); } if (!$clock || $clock === 'cpu') { $ru = wfGetRusage(); if ($ru) { $ret['cpu'] = $ru['ru_utime.tv_sec'] + $ru['ru_utime.tv_usec'] / 1000000.0; $ret['cpu'] += $ru['ru_stime.tv_sec'] + $ru['ru_stime.tv_usec'] / 1000000.0; } } return $ret; }
/** * Get the initial time of the request, based on getrusage() * * @param string|bool $metric Metric to use, with the following possibilities: * - user: User CPU time (without system calls) * - cpu: Total CPU time (user and system calls) * - wall (or any other string): elapsed time * - false (default): will fall back to default metric * @return float */ protected function getTime($metric = 'wall') { if ($metric === 'cpu' || $metric === 'user') { $ru = wfGetRusage(); if (!$ru) { return 0; } $time = $ru['ru_utime.tv_sec'] + $ru['ru_utime.tv_usec'] / 1000000.0; if ($metric === 'cpu') { # This is the time of system calls, added to the user time # it gives the total CPU time $time += $ru['ru_stime.tv_sec'] + $ru['ru_stime.tv_usec'] / 1000000.0; } return $time; } else { return microtime(true); } }