/** * Commit new records. * * @return void */ public function commit() { $request = (object) array('pid' => getmypid(), 'threadid' => ZEND_THREAD_SAFE ? zend_thread_id() : null, 'uid' => getmyuid(), 'url' => $this->url->out_as_local_url(false), 'hostname' => gethostname(), 'memory' => memory_get_usage(), 'peakmemory' => memory_get_peak_usage()); // Not supported on Windows until PHP 7 if (function_exists('getrusage')) { $resourceusage = getrusage(); $request->numswaps = $resourceusage['ru_nswap']; $request->numpagefaults = $resourceusage['ru_majflt']; $request->usertime = $resourceusage['ru_utime.tv_usec']; } $request->id = $this->db->insert_record('telemetry_request', $request); foreach ($this->additionalstate as $collector) { $table = $collector->get_table(); $records = $collector->get_records(); foreach ($records as $record) { $record->requestid = $request->id; } $this->db->insert_records($table, $records); } }
function getCpuTime($ru = null) { if ($ru == null) { $ru = getrusage(); } return $ru['ru_utime.tv_sec'] + $ru['ru_stime.tv_sec'] + ($ru['ru_utime.tv_usec'] + $ru['ru_stime.tv_usec']) * 1.0E-6; }
public function getCpuUsage() { $proc = getrusage(); $proc["ru_utime.tv_usec"] = $proc["ru_utime.tv_sec"] * 1000000.0 + $proc["ru_utime.tv_usec"] - $this->rusage; $time = (microtime(true) - $this->tusage) * 1000000; return $time > 0 ? sprintf("%01.2f", $proc["ru_utime.tv_usec"] / $time * 100) : '0.00'; }
function thold_display_rusage() { global $thold_start_rusage; if (function_exists('getrusage')) { $dat = getrusage(); html_start_box('', '100%', '', '3', 'left', ''); print '<tr>'; if (!isset($thold_start_rusage)) { print "<td colspan='10'>ERROR: Can not display RUSAGE please call thold_initialize_rusage first</td>"; } else { $i_u_time = $thold_start_rusage['ru_utime.tv_sec'] + $thold_start_rusage['ru_utime.tv_usec'] * 1.0E-6; $i_s_time = $thold_start_rusage['ru_stime.tv_sec'] + $thold_start_rusage['ru_stime.tv_usec'] * 1.0E-6; $s_s = $thold_start_rusage['ru_nswap']; $s_pf = $thold_start_rusage['ru_majflt']; list($micro, $seconds) = explode(' ', $thold_start_rusage['microtime']); $start_time = $seconds + $micro; list($micro, $seconds) = explode(' ', microtime()); $end_time = $seconds + $micro; $utime = $dat['ru_utime.tv_sec'] + $dat['ru_utime.tv_usec'] * 1.0E-6 - $i_u_time; $stime = $dat['ru_stime.tv_sec'] + $dat['ru_stime.tv_usec'] * 1.0E-6 - $i_s_time; $swaps = $dat['ru_nswap'] - $s_s; $pages = $dat['ru_majflt'] - $s_pf; print "<td colspan='10' width='1%' style='text-align:left;'>"; print '<b>' . __('Time:') . '</b> ' . round($end_time - $start_time, 2) . ' seconds, '; print '<b>' . __('User:'******'</b> ' . round($utime, 2) . ' seconds, '; print '<b>' . __('System:') . '</b> ' . round($stime, 2) . ' seconds, '; print '<b>' . __('Swaps:') . '</b> ' . $swaps . ' swaps, '; print '<b>' . __('Pages:') . '</b> ' . $pages . ' pages'; print '</td>'; } print '</tr>'; html_end_box(false); } }
function thold_display_rusage() { global $colors, $thold_start_rusage; if (function_exists("getrusage")) { $dat = getrusage(); html_start_box("", "100%", $colors["header"], "3", "left", ""); print "<tr>"; if (!isset($thold_start_rusage)) { print "<td colspan='10'>ERROR: Can not display RUSAGE please call thold_initialize_rusage first</td>"; } else { $i_u_time = $thold_start_rusage["ru_utime.tv_sec"] + $thold_start_rusage["ru_utime.tv_usec"] * 1.0E-6; $i_s_time = $thold_start_rusage["ru_stime.tv_sec"] + $thold_start_rusage["ru_stime.tv_usec"] * 1.0E-6; $s_s = $thold_start_rusage["ru_nswap"]; $s_pf = $thold_start_rusage["ru_majflt"]; list($micro, $seconds) = split(" ", $thold_start_rusage["microtime"]); $start_time = $seconds + $micro; list($micro, $seconds) = split(" ", microtime()); $end_time = $seconds + $micro; $utime = $dat["ru_utime.tv_sec"] + $dat["ru_utime.tv_usec"] * 1.0E-6 - $i_u_time; $stime = $dat["ru_stime.tv_sec"] + $dat["ru_stime.tv_usec"] * 1.0E-6 - $i_s_time; $swaps = $dat["ru_nswap"] - $s_s; $pages = $dat["ru_majflt"] - $s_pf; print "<td colspan='10' width='1%' style='text-align:left;'>"; print "<b>Time:</b> " . round($end_time - $start_time, 2) . " seconds, "; print "<b>User:</b> " . round($utime, 2) . " seconds, "; print "<b>System:</b> " . round($stime, 2) . " seconds, "; print "<b>Swaps:</b> " . $swaps . " swaps, "; print "<b>Pages:</b> " . $pages . " pages"; print "</td>"; } print "</tr>"; html_end_box(false); } }
private function getTimeUsage() { if (!function_exists('getrusage')) { return null; } $ru = getrusage(); return array('user_time' => $ru['ru_utime.tv_sec'] + $ru['ru_utime.tv_usec'] / 1000000, 'system_time' => $ru['ru_stime.tv_sec'] + $ru['ru_stime.tv_usec'] / 1000000); }
public static function cpuTime() { $dat = getrusage(); $tv_usec = $dat["ru_utime.tv_sec"] * 1000000.0 + $dat["ru_utime.tv_usec"] - self::$RUSAGE; $time = (microtime(true) - self::$TUSAGE) * 1000000.0; $cpuusage = $tv_usec / $time; return round($time / 1000 * $cpuusage); }
/** * @param $name * @param $type */ public function log($name, $type) { if (!array_key_exists($type, $this->_typeList)) { throw new \InvalidArgumentException("Type {$type} is incorrect"); } $cpu = getrusage(); $this->_message[] = ['type' => $type, 'message' => $name, 'time' => microtime(true), 'memory' => memory_get_usage(true), 'cpu' => $cpu['ru_utime.tv_usec'] + $cpu['ru_stime.tv_usec']]; }
public function sendHeaders($serverErrorString = null) { // check we can send these first if (headers_sent()) { throw new ImThumbException("Could not set image headers, output already started", ImThumb::ERR_OUTPUTTING); } $modifiedDate = gmdate('D, d M Y H:i:s') . ' GMT'; // get image size. Have to workaround bugs in Imagick that return 0 for size by counting ourselves. $byteSize = $this->image->getImageSize(); if ($this->image->hasBrowserCache()) { header('HTTP/1.0 304 Not Modified'); } else { if ($serverErrorString) { header('HTTP/1.0 500 Internal Server Error'); header('X-ImThumb-Error: ' . $serverErrorString); } else { if (!$this->image->isValid()) { header('HTTP/1.0 404 Not Found'); } else { header('HTTP/1.0 200 OK'); } } header('Content-Type: ' . $this->image->getMime()); header('Accept-Ranges: none'); header('Last-Modified: ' . $modifiedDate); header('Content-Length: ' . $byteSize); if (!$this->image->param('browserCache')) { header('Cache-Control: no-store, no-cache, must-revalidate, max-age=0'); header("Pragma: no-cache"); header('Expires: ' . gmdate('D, d M Y H:i:s', time())); } else { $maxAge = $this->image->param('browserCacheMaxAge'); $expiryDate = gmdate('D, d M Y H:i:s', strtotime('now +' . $maxAge . ' seconds')) . ' GMT'; header('Cache-Control: max-age=' . $maxAge . ', must-revalidate'); header('Expires: ' . $expiryDate); } } // informational headers if (!$this->image->param('silent')) { $im = new Imagick(); $imVer = $im->getVersion(); header('X-Generator: ImThumb v' . ImThumb::VERSION . '; ' . $imVer['versionString']); if ($this->image->cache && $this->image->cache->isCached()) { header('X-Img-Cache: HIT'); } else { header('X-Img-Cache: MISS'); } if ($this->image->param('debug')) { list($startTime, $startCPU_u, $startCPU_s) = $this->image->getTimingStats(); header('X-Generated-In: ' . number_format(microtime(true) - $startTime, 6) . 's'); header('X-Memory-Peak: ' . number_format(memory_get_peak_usage() / 1024, 3, '.', '') . 'KB'); $data = getrusage(); $memusage = array((double) ($data['ru_utime.tv_sec'] + $data['ru_utime.tv_usec'] / 1000000), (double) ($data['ru_stime.tv_sec'] + $data['ru_stime.tv_usec'] / 1000000)); header('X-CPU-Utilisation:' . ' Usr ' . number_format($memusage[0] - $startCPU_u, 6) . ', Sys ' . number_format($memusage[1] - $startCPU_s, 6) . '; Base ' . number_format($startCPU_u, 6) . ', ' . number_format($startCPU_s, 6)); } } }
public function printResult() { $ru = getrusage(); $time = microtime(true) - $_SERVER["REQUEST_TIME_FLOAT"]; echo '<b>Memory :</b> ' . memory_get_peak_usage() . '<br />'; echo '<b>Process Time :</b> ' . $time * 1000 . ' ms<br />'; echo 'This process used ' . self::_getrtime($ru, $this->start, "utime") . ' ms for its computations<br />'; echo 'It spent ' . self::_getrtime($ru, $this->start, "stime") . ' ms in system calls'; }
public function stop_time() { $e_tmr = count($this->etime); $this->etime[$e_tmr] = getrusage(); $ctime = $this->calc_time($this->etime[$e_tmr], $this->stime[$e_tmr], "utime"); $sctime = $this->calc_time($this->etime[$e_tmr], $this->stime[$e_tmr], "stime"); $this->results[$e_tmr]['compute'] = $ctime . " ms"; $this->results[$e_tmr]['calls'] = $sctime . " ms"; }
function randomBytes($length = 16, $secure = true, $raw = true, $startEntropy = "", &$rounds = 0, &$drop = 0) { static $lastRandom = ""; $output = ""; $length = abs((int) $length); $secureValue = ""; $rounds = 0; $drop = 0; while (!isset($output[$length - 1])) { //some entropy, but works ^^ $weakEntropy = array(is_array($startEntropy) ? implode($startEntropy) : $startEntropy, serialize(stat(__FILE__)), __DIR__, PHP_OS, microtime(), (string) lcg_value(), (string) PHP_MAXPATHLEN, PHP_SAPI, (string) PHP_INT_MAX . "." . PHP_INT_SIZE, serialize($_SERVER), serialize(get_defined_constants()), get_current_user(), serialize(ini_get_all()), (string) memory_get_usage() . "." . memory_get_peak_usage(), php_uname(), phpversion(), extension_loaded("gmp") ? gmp_strval(gmp_random(4)) : microtime(), zend_version(), (string) getmypid(), (string) getmyuid(), (string) mt_rand(), (string) getmyinode(), (string) getmygid(), (string) rand(), function_exists("zend_thread_id") ? (string) zend_thread_id() : microtime(), var_export(@get_browser(), true), function_exists("getrusage") ? @implode(getrusage()) : microtime(), function_exists("sys_getloadavg") ? @implode(sys_getloadavg()) : microtime(), serialize(get_loaded_extensions()), sys_get_temp_dir(), (string) disk_free_space("."), (string) disk_total_space("."), uniqid(microtime(), true), file_exists("/proc/cpuinfo") ? file_get_contents("/proc/cpuinfo") : microtime()); shuffle($weakEntropy); $value = hash("sha512", implode($weakEntropy), true); $lastRandom .= $value; foreach ($weakEntropy as $k => $c) { //mixing entropy values with XOR and hash randomness extractor $value ^= hash("sha256", $c . microtime() . $k, true) . hash("sha256", mt_rand() . microtime() . $k . $c, true); $value ^= hash("sha512", (string) lcg_value() . $c . microtime() . $k, true); } unset($weakEntropy); if ($secure === true) { $strongEntropyValues = array(is_array($startEntropy) ? hash("sha512", $startEntropy[($rounds + $drop) % count($startEntropy)], true) : hash("sha512", $startEntropy, true), file_exists("/dev/urandom") ? fread(fopen("/dev/urandom", "rb"), 64) : str_repeat("", 64), (function_exists("openssl_random_pseudo_bytes") and version_compare(PHP_VERSION, "5.3.4", ">=")) ? openssl_random_pseudo_bytes(64) : str_repeat("", 64), function_exists("mcrypt_create_iv") ? mcrypt_create_iv(64, MCRYPT_DEV_URANDOM) : str_repeat("", 64), $value); $strongEntropy = array_pop($strongEntropyValues); foreach ($strongEntropyValues as $value) { $strongEntropy = $strongEntropy ^ $value; } $value = ""; //Von Neumann randomness extractor, increases entropy $bitcnt = 0; for ($j = 0; $j < 64; ++$j) { $a = ord($strongEntropy[$j]); for ($i = 0; $i < 8; $i += 2) { $b = ($a & 1 << $i) > 0 ? 1 : 0; if ($b != (($a & 1 << $i + 1) > 0 ? 1 : 0)) { $secureValue |= $b << $bitcnt; if ($bitcnt == 7) { $value .= chr($secureValue); $secureValue = 0; $bitcnt = 0; } else { ++$bitcnt; } ++$drop; } else { $drop += 2; } } } } $output .= substr($value, 0, min($length - strlen($output), $length)); unset($value); ++$rounds; } $lastRandom = hash("sha512", $lastRandom, true); return $raw === false ? bin2hex($output) : $output; }
/** * Get system resource usage of current request context. * Invokes the getrusage(2) system call, requesting RUSAGE_SELF if on PHP5 * or RUSAGE_THREAD if on HHVM. Returns false if getrusage is not available. * * @since 1.24 * @return array|bool Resource usage data or false if no data available. */ function wfGetRusage() { if (!function_exists('getrusage')) { return false; } elseif (defined('HHVM_VERSION')) { return getrusage(2); } else { return getrusage(0); } }
public static function getNow() { $time = microtime(true); $usage = getrusage(); $child_usage = getrusage(1); $sys_time = sprintf("%d.%f", $usage["ru_stime.tv_sec"], $usage["ru_stime.tv_usec"]); $user_time = sprintf("%d.%f", $usage["ru_utime.tv_sec"], $usage["ru_utime.tv_usec"]); $child_sys_time = sprintf("%d.%f", $child_usage["ru_stime.tv_sec"], $child_usage["ru_stime.tv_usec"]); $child_user_time = sprintf("%d.%f", $child_usage["ru_utime.tv_sec"], $child_usage["ru_utime.tv_usec"]); return new Time($time, $sys_time, $user_time, $child_sys_time, $child_user_time); }
protected function getUsage() { /* * getrusage is not available on windows with php < 7 */ if (!function_exists('getrusage')) { return 0; } $cpu = getrusage(); return $cpu["ru_utime.tv_sec"] * 1000000.0 + $cpu["ru_utime.tv_usec"]; }
public function _save() { $root = self::_calculate_item(array_pop(self::$_stack)); $result = array('url' => $_SERVER['REQUEST_URI'], 'microtime' => $this->_microtime, 'data' => $root, 'log' => self::$_log, 'included_files' => get_included_files(), 'declared_classes' => get_declared_classes(), 'memory' => array('usage' => memory_get_usage(), 'peak' => memory_get_peak_usage()), 'rusage' => getrusage(), 'queries' => Database::$log, 'post' => $_POST, 'get' => $_GET); $json = json_encode($result, JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE | JSON_PRETTY_PRINT); $microtime = explode(' ', $this->_microtime); $seconds = $microtime[1]; $millis = $microtime[0]; $filename = $seconds . '[' . $millis . '].json'; file_put_contents($this->_cwd . '/profiling/' . $filename, $json); }
/** * Return an array representing the resource usage as of now. */ public function getCurrent() { $usage = array('files' => count(get_included_files()), 'queries' => $this->databaseUsage['queries'], 'ram' => function_exists('memory_get_usage') ? memory_get_usage() : 0, 'clock' => array_sum(explode(' ', microtime())), 'mysql' => $this->databaseUsage['clock']); if (function_exists('getrusage')) { $rusage = getrusage(); $usage['cpu'] = $rusage["ru_utime.tv_sec"] + $rusage["ru_stime.tv_sec"] + ($rusage["ru_utime.tv_usec"] + $rusage["ru_stime.tv_usec"]) / 1000000; } else { $usage['cpu'] = 0; } $usage['other'] = $usage['clock'] - $usage['cpu'] - $usage['mysql']; return $usage; }
public function start() { if ($this->started) { throw new RuntimeException("Already started."); } $this->startTime = microtime(true); $this->stopTime = $this->startTime; $rusage = getrusage(); $this->startUsage = $this->getResourceUsage(); $this->stopUsage = $this->startUsage; $this->started = true; }
function _rus($end = false) { $this->buff = getrusage(); if ($end) { $this->rtime = microtime(true) - $this->rtime; $this->utime = floatval($this->buff["ru_utime.tv_sec"] . $this->buff["ru_utime.tv_usec"] - $this->utime) / 1000000.0; $this->stime = floatval($this->buff["ru_stime.tv_sec"] . $this->buff["ru_stime.tv_usec"] - $this->stime) / 1000000.0; } else { $this->rtime = microtime(true); $this->utime = $this->buff["ru_utime.tv_sec"] . $this->buff["ru_utime.tv_usec"]; $this->stime = $this->buff["ru_stime.tv_sec"] . $this->buff["ru_stime.tv_usec"]; } }
public static function getCpuUsage() { $dat = getrusage(); $dat["ru_utime.tv_usec"] = $dat["ru_utime.tv_sec"] * 1000000.0 + $dat["ru_utime.tv_usec"] - PHP_RUSAGE; $time = (microtime(true) - PHP_TUSAGE) * 1000000; // cpu per request if ($time > 0) { $cpu = sprintf("%01.2f", $dat["ru_utime.tv_usec"] / $time * 100); } else { $cpu = '0.00'; } return $cpu; }
function getCpuUsage() { // http://php.webtutor.pl/en/2011/05/13/how-to-calculate-cpu-usage-of-a-php-script/ $dat = getrusage(); $dat["ru_utime.tv_usec"] = ($dat["ru_utime.tv_sec"]*1e6 + $dat["ru_utime.tv_usec"]) - PHP_RUSAGE; $time = (microtime(true) - PHP_TUSAGE) * 1000000; // cpu per request if($time > 0) { $cpu = sprintf("%01.2f", ($dat["ru_utime.tv_usec"] / $time) * 100); } else { $cpu = '0.00'; } return $cpu; }
function paymill_doBenchmark($clear = false, $feature, $shutdown = false) { if (function_exists('getrusage')) { if ($shutdown) { if (function_exists('current_user_can') && function_exists('wp_get_current_user') && current_user_can('administrator')) { $userSum = 0; $systemSum = 0; $sum = 0; echo '<table id="paymillBenchmark" style="border-spacing: 10px;border-collapse: separate;">'; echo '<tr><th><strong>Feature</strong></th><th><strong>User Time</strong></th><th><strong>System Time</strong></th><th><strong>Sum</strong></th></tr>'; foreach ($GLOBALS['paymillBenchmark'] as $feature => $data) { echo '<tr><td>' . $feature . '</td><td>' . $data['userTime'] . '</td><td>' . $data['systemTime'] . '</td><td>' . $data['sumTime'] . '</td></tr>'; $userSum = $userSum + $data['userTime']; $systemSum = $systemSum + $data['systemTime']; $sum = $sum + $data['sumTime']; } echo '<tr><td><strong>Sum</strong></th><td><strong>' . $userSum . '</strong></td><td><strong>' . $systemSum . '</strong></td><td><strong>' . $sum . '</strong></td></tr>'; echo '</table>'; global $wpdb; echo "<pre>"; var_dump($wpdb->queries); echo "</pre>"; } } else { static $stime; static $utime; static $sumtime; $ru = getrusage(); $currentUTime = $ru['ru_utime.tv_sec'] + round($ru['ru_utime.tv_usec'] / 1000000, 4); $currentSTime = $ru['ru_stime.tv_sec'] + round($ru['ru_stime.tv_usec'] / 1000000, 4); $currentSumTime = $currentUTime + $currentSTime; if (($stime || $utime) && !$clear) { $benchmarkU = $currentUTime - $utime; $benchmarkS = $currentSTime - $stime; if (isset($GLOBALS['paymillBenchmark'][$feature]['userTime'])) { $GLOBALS['paymillBenchmark'][$feature]['userTime'] = $GLOBALS['paymillBenchmark'][$feature]['userTime'] + $benchmarkU; $GLOBALS['paymillBenchmark'][$feature]['systemTime'] = $GLOBALS['paymillBenchmark'][$feature]['systemTime'] + $benchmarkS; $GLOBALS['paymillBenchmark'][$feature]['sumTime'] = $GLOBALS['paymillBenchmark'][$feature]['sumTime'] + $benchmarkU + $benchmarkS; } else { $GLOBALS['paymillBenchmark'][$feature]['userTime'] = $benchmarkU; $GLOBALS['paymillBenchmark'][$feature]['systemTime'] = $benchmarkS; $GLOBALS['paymillBenchmark'][$feature]['sumTime'] = $benchmarkU + $benchmarkS; } } $utime = $currentUTime; $stime = $currentSTime; } } }
function read(){ if(is_numeric($this->stop) && is_numeric($this->start) && ($this->stop > $this->start)){ return ($this->stop - $this->start); }else if(is_numeric($this->start)){ $ru = getrusage(); $currentTime = $ru['ru_stime.tv_sec'] + round($ru['ru_stime.tv_usec']/1000000, 4); return ($currentTime - $this->start); }else{ return 0; } }
/** * Return usage. * @param * $format: array or string. * @return * Result of calling getrusage() in form of an array or a string. */ public function Usage($format = 'array') { // Return array by default. $data = ''; switch ($this->format) { case 'array': $data = getrusage(); break; case 'string': $data = str_replace('&', ', ', http_build_query(getrusage())); break; case 'json': $data = json_encode(getrusage()); break; } return $data; }
function W5mf7Y9Huk0KaQU6() { global $XhI5oWumotgSTXQVVqo, $IYxAjJo0uTeBRoqu, $Sg9qW4hdbZ, $grab_parameters; $ctime = time(); if ($ctime - $Sg9qW4hdbZ > 15) { IHysls0Hqo9YVUNMhHR(); } $Sg9qW4hdbZ = $ctime; if (!function_exists('getrusage')) { return; } if (!isset($IYxAjJo0uTeBRoqu)) { $IYxAjJo0uTeBRoqu = explode('|', $grab_parameters['xs_cpumon']); } if (!is_array($IYxAjJo0uTeBRoqu) || !$IYxAjJo0uTeBRoqu[0]) { return; } $g192oehb7n = microtime(true); if (($bG6_Xft9xSIFOd = $g192oehb7n - $XhI5oWumotgSTXQVVqo[1]) < $IYxAjJo0uTeBRoqu[3]) { return; } $FA0UpNye2M37wP7LQ = getrusage(); $FwAmnjOOVT9HzKSJ = ($FA0UpNye2M37wP7LQ["ru_utime.tv_sec"] * 1000000.0 + $FA0UpNye2M37wP7LQ["ru_utime.tv_usec"]) / 1000000.0; $Fpei00GZKLxgY3rk = 0; if ($XhI5oWumotgSTXQVVqo) { $xpgWgyK6WCPjyJ = $FwAmnjOOVT9HzKSJ - $XhI5oWumotgSTXQVVqo[0]; $Fpei00GZKLxgY3rk = 100 * $xpgWgyK6WCPjyJ / $bG6_Xft9xSIFOd; } if ($Fpei00GZKLxgY3rk > $IYxAjJo0uTeBRoqu[0]) { fTr9xtaaPTXU("\n<br>CPU monitor sleep: " . number_format($Fpei00GZKLxgY3rk, 2) . "% (" . number_format($xpgWgyK6WCPjyJ, 2) . " / " . number_format($bG6_Xft9xSIFOd, 2) . " / " . number_format($g192oehb7n - $XhI5oWumotgSTXQVVqo[2], 2) . " ) " . (number_format(memory_get_usage() / 1024) . 'K')); $XhI5oWumotgSTXQVVqo[2] = $g192oehb7n + $IYxAjJo0uTeBRoqu[1]; sleep($IYxAjJo0uTeBRoqu[1]); fTr9xtaaPTXU(".. go\n<br>"); } else { if ($bG6_Xft9xSIFOd > $IYxAjJo0uTeBRoqu[2]) { $XhI5oWumotgSTXQVVqo[0] = $FwAmnjOOVT9HzKSJ; $XhI5oWumotgSTXQVVqo[1] = $g192oehb7n; } } }
public function __construct(array $params = null) { if (!class_exists('Imagick')) { throw new ImThumbException("Could not load ImThumb: ImageMagick is not installed. Please contact your webhost and ask them to install the ImageMagick library", self::ERR_SERVER_CONFIG); } $this->startTime = microtime(true); if (defined('MEMORY_LIMIT') && MEMORY_LIMIT) { ini_set('memory_limit', MEMORY_LIMIT); } ksort($params); // :NOTE: order the parameters to get consistent cache filenames, as this is factored into filename hashes $this->params = $params; // store initial CPU stats if we are debugging if ($this->param('debug')) { $data = getrusage(); $this->startCPU = array((double) ($data['ru_utime.tv_sec'] + $data['ru_utime.tv_usec'] / 1000000), (double) ($data['ru_stime.tv_sec'] + $data['ru_stime.tv_usec'] / 1000000)); } // set default width / height if none provided if (!$this->param('width') && !$this->param('height') && !$this->params('cropRect')) { $this->params['width'] = $this->params['height'] = self::DEFAULT_SIZE; } }
function execute() { if ($this->hasOption('tpl-time')) { $this->templateTimestamp = wfTimestamp(TS_MW, strtotime($this->getOption('tpl-time'))); Hooks::register('BeforeParserFetchTemplateAndtitle', array($this, 'onFetchTemplate')); } $title = Title::newFromText($this->getArg()); if (!$title) { $this->error("Invalid title"); exit(1); } if ($this->hasOption('page-time')) { $pageTimestamp = wfTimestamp(TS_MW, strtotime($this->getOption('page-time'))); $id = $this->getRevIdForTime($title, $pageTimestamp); if (!$id) { $this->error("The page did not exist at that time"); exit(1); } $revision = Revision::newFromId($id); } else { $revision = Revision::newFromTitle($title); } if (!$revision) { $this->error("Unable to load revision, incorrect title?"); exit(1); } if (!$this->hasOption('cold')) { $this->runParser($revision); } $startUsage = getrusage(); $startTime = microtime(true); $this->runParser($revision); $endUsage = getrusage(); $endTime = microtime(true); printf("CPU time = %.3f s, wall clock time = %.3f s\n", $endUsage['ru_utime.tv_sec'] + $endUsage['ru_utime.tv_usec'] * 1.0E-6 - $startUsage['ru_utime.tv_sec'] - $startUsage['ru_utime.tv_usec'] * 1.0E-6, $endTime - $startTime); }
function StopWatch($x) { global $StopWatch, $EnableStopWatch; if (!$EnableStopWatch) return; static $wstart = 0, $ustart = 0; list($usec,$sec) = explode(' ',microtime()); $wtime = ($sec+$usec); if (!$wstart) $wstart = $wtime; if ($EnableStopWatch != 2) { $StopWatch[] = sprintf("%05.2f %s", $wtime-$wstart, $x); return; } $dat = getrusage(); $utime = ($dat['ru_utime.tv_sec']+$dat['ru_utime.tv_usec']/1000000); if (!$ustart) $ustart=$utime; $StopWatch[] = sprintf("%05.2f %05.2f %s", $wtime-$wstart, $utime-$ustart, $x); }
<?php /* Prototype : array getrusage ([ int $who ] ) * Description: Gets the current resource usages * Source code: ext/standard/microtime.c * Alias to functions: */ /* * Pass different data types as $who argument to test behaviour of getrusage() */ echo "*** Testing getrusage() : usage variations ***\n"; //get an unset variable $unset_var = 10; unset($unset_var); // unexpected values to be passed to $stream_id argument $inputs = array(0, 1, 12345, -2345, 10.5, -10.5, 123456789000.0, 1.23456789E-9, 0.5, NULL, null, true, false, TRUE, FALSE, "0", '1', "1232456", "1.23E4", @$undefined_var, @$unset_var); // loop through each element of $inputs to check the behavior of getrusage() $iterator = 1; foreach ($inputs as $input) { echo "\n-- Iteration {$iterator} --\n"; $res = getrusage($input); echo "User time used (microseconds) " . $res["ru_utime.tv_usec"] . "\n"; $iterator++; } ?> ===DONE===
// Clock time during page render $db_time = number_format($db_time, 2); // Clock time in DB render $dbPercent = number_format($dbPercent, 0); // DB as percent of clock $memuse = eHelper::getMemoryUsage(); // Memory at end, in B/KB/MB/GB ;) $queryCount = $sql->db_QueryCount(); $rinfo = ''; $logLine = ''; if ($pref['log_page_accesses']) { // Collect the first batch of data to log $logLine .= "'" . ($now = time()) . "','" . gmstrftime('%y-%m-%d %H:%M:%S', $now) . "','" . e107::getIPHandler()->getIP(FALSE) . "','" . e_PAGE . '?' . e_QUERY . "','" . $rendertime . "','" . $db_time . "','" . $queryCount . "','" . $memuse . "','" . $_SERVER['HTTP_USER_AGENT'] . "','{$_SERVER["REQUEST_METHOD"]}'"; } if (function_exists('getrusage')) { $ru = getrusage(); $cpuUTime = $ru['ru_utime.tv_sec'] + $ru['ru_utime.tv_usec'] * 1.0E-6; $cpuSTime = $ru['ru_stime.tv_sec'] + $ru['ru_stime.tv_usec'] * 1.0E-6; $cpuUStart = $eTimingStartCPU['ru_utime.tv_sec'] + $eTimingStartCPU['ru_utime.tv_usec'] * 1.0E-6; $cpuSStart = $eTimingStartCPU['ru_stime.tv_sec'] + $eTimingStartCPU['ru_stime.tv_usec'] * 1.0E-6; $cpuStart = $cpuUStart + $cpuSStart; $cpuTot = $cpuUTime + $cpuSTime; $cpuTime = $cpuTot - $cpuStart; $cpuPct = 100.0 * $cpuTime / $rendertime; /* CPU load during known clock time */ // Format for display or logging (Uncomment as needed for logging) //$cpuUTime = number_format($cpuUTime, 3); // User cpu //$cpuSTime = number_format($cpuSTime, 3); // System cpu //$cpuTot = number_format($cpuTot, 3); // Total (User+System) $cpuStart = number_format($cpuStart, 3); // Startup time (i.e. CPU used before class2.php)