• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP posix_times函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了PHP中posix_times函数的典型用法代码示例。如果您正苦于以下问题:PHP posix_times函数的具体用法?PHP posix_times怎么用?PHP posix_times使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了posix_times函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。

示例1: init_performance_info

/**
 * Initializes our performance info early.
 *
 * Pairs up with get_performance_info() which is actually
 * in moodlelib.php. This function is here so that we can 
 * call it before all the libs are pulled in. 
 *
 * @uses $PERF
 */
function init_performance_info()
{
    global $PERF, $CFG, $USER;
    $PERF = new Object();
    $PERF->dbqueries = 0;
    $PERF->logwrites = 0;
    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();
    }
    if (function_exists('apd_set_pprof_trace')) {
        // APD profiling
        if ($USER->id > 0 && $CFG->perfdebug >= 15) {
            $tempdir = $CFG->dataroot . '/temp/profile/' . $USER->id;
            mkdir($tempdir);
            apd_set_pprof_trace($tempdir);
            $PERF->profiling = true;
        }
    }
}
开发者ID:BackupTheBerlios,项目名称:samouk-svn,代码行数:34,代码来源:setuplib.php


示例2: __construct

 public function __construct()
 {
     $state = '';
     if (function_exists('posix_times')) {
         $state .= serialize(posix_times());
     }
     $state .= getmypid() . memory_get_usage();
     $state .= serialize($_ENV);
     $this->state = hash('sha512', $state, true);
 }
开发者ID:chansolo,项目名称:TeamPass,代码行数:10,代码来源:MicroTime.php


示例3: init_performance_info

/**
 * Initializes our performance info early.
 *
 * Pairs up with get_performance_info() which is actually
 * in moodlelib.php. This function is here so that we can 
 * call it before all the libs are pulled in. 
 *
 * @uses $PERF
 */
function init_performance_info()
{
    global $PERF;
    $PERF = new Object();
    $PERF->dbqueries = 0;
    $PERF->logwrites = 0;
    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();
    }
}
开发者ID:veritech,项目名称:pare-project,代码行数:25,代码来源:setuplib.php


示例4: stop

 public function stop()
 {
     $this->endreadable = date(DATE_ATOM);
     $this->endtime = microtime(true);
     $this->endptimes = posix_times();
     $this->serverloadend = $this->get_load();
     $this->realtime = $this->endtime - $this->starttime;
     $this->endmemorytotal = memory_get_usage();
     $this->endmemorytotalreal = memory_get_usage(true);
     $this->memorypeak = memory_get_peak_usage();
     $this->memorypeakreal = memory_get_peak_usage(true);
     $this->stopptimes = posix_times();
     $info = array();
     foreach ($this->stopptimes as $key => $val) {
         $info[$key] = $this->stopptimes[$key] - $this->startptimes[$key];
     }
     $this->ticks = "Ticks: {$info['ticks']} user: {$info['utime']} sys: {$info['stime']} cuser: {$info['cutime']} csys: {$info['cstime']} ";
 }
开发者ID:dariogs,项目名称:moosh,代码行数:18,代码来源:Performance.php


示例5: __construct

 public function __construct()
 {
     $state = self::$state;
     if (function_exists('posix_times')) {
         $state .= serialize(posix_times());
     }
     if (function_exists('zend_thread_id')) {
         $state .= zend_thread_id();
     }
     $state .= getmypid() . memory_get_usage();
     $state .= serialize($_ENV);
     $state .= serialize($_SERVER);
     $state .= count(debug_backtrace(false));
     self::$state = hash('sha512', $state, true);
     if (is_null(self::$counter)) {
         list(, self::$counter) = unpack("i", substr(self::$state, 0, 4));
         $seed = $this->generate(strlen(dechex(PHP_INT_MAX)));
         list(, self::$counter) = unpack("i", $seed);
     }
 }
开发者ID:zqcloveping,项目名称:pagekit,代码行数:20,代码来源:MicroTime.php


示例6: get_performance_info

/**
 * get_performance_info() pairs up with init_performance_info()
 * loaded in setup.php. Returns an array with 'html' and 'txt'
 * values ready for use, and each of the individual stats provided
 * separately as well.
 *
 * @global object
 * @global object
 * @global object
 * @return array
 */
function get_performance_info()
{
    global $CFG, $PERF, $DB, $PAGE;
    $info = array();
    $info['html'] = '';
    // holds userfriendly HTML representation
    $info['txt'] = me() . ' ';
    // holds log-friendly representation
    $info['realtime'] = microtime_diff($PERF->starttime, microtime());
    $info['html'] .= '<span class="timeused">' . $info['realtime'] . ' secs</span> ';
    $info['txt'] .= 'time: ' . $info['realtime'] . 's ';
    if (function_exists('memory_get_usage')) {
        $info['memory_total'] = memory_get_usage();
        $info['memory_growth'] = memory_get_usage() - $PERF->startmemory;
        $info['html'] .= '<span class="memoryused">RAM: ' . display_size($info['memory_total']) . '</span> ';
        $info['txt'] .= 'memory_total: ' . $info['memory_total'] . 'B (' . display_size($info['memory_total']) . ') memory_growth: ' . $info['memory_growth'] . 'B (' . display_size($info['memory_growth']) . ') ';
    }
    if (function_exists('memory_get_peak_usage')) {
        $info['memory_peak'] = memory_get_peak_usage();
        $info['html'] .= '<span class="memoryused">RAM peak: ' . display_size($info['memory_peak']) . '</span> ';
        $info['txt'] .= 'memory_peak: ' . $info['memory_peak'] . 'B (' . display_size($info['memory_peak']) . ') ';
    }
    $inc = get_included_files();
    //error_log(print_r($inc,1));
    $info['includecount'] = count($inc);
    $info['html'] .= '<span class="included">Included ' . $info['includecount'] . ' files</span> ';
    $info['txt'] .= 'includecount: ' . $info['includecount'] . ' ';
    $filtermanager = filter_manager::instance();
    if (method_exists($filtermanager, 'get_performance_summary')) {
        list($filterinfo, $nicenames) = $filtermanager->get_performance_summary();
        $info = array_merge($filterinfo, $info);
        foreach ($filterinfo as $key => $value) {
            $info['html'] .= "<span class='{$key}'>{$nicenames[$key]}: {$value} </span> ";
            $info['txt'] .= "{$key}: {$value} ";
        }
    }
    $stringmanager = get_string_manager();
    if (method_exists($stringmanager, 'get_performance_summary')) {
        list($filterinfo, $nicenames) = $stringmanager->get_performance_summary();
        $info = array_merge($filterinfo, $info);
        foreach ($filterinfo as $key => $value) {
            $info['html'] .= "<span class='{$key}'>{$nicenames[$key]}: {$value} </span> ";
            $info['txt'] .= "{$key}: {$value} ";
        }
    }
    $jsmodules = $PAGE->requires->get_loaded_modules();
    if ($jsmodules) {
        $yuicount = 0;
        $othercount = 0;
        $details = '';
        foreach ($jsmodules as $module => $backtraces) {
            if (strpos($module, 'yui') === 0) {
                $yuicount += 1;
            } else {
                $othercount += 1;
            }
            $details .= "<div class='yui-module'><p>{$module}</p>";
            foreach ($backtraces as $backtrace) {
                $details .= "<div class='backtrace'>{$backtrace}</div>";
            }
            $details .= '</div>';
        }
        $info['html'] .= "<span class='includedyuimodules'>Included YUI modules: {$yuicount}</span> ";
        $info['txt'] .= "includedyuimodules: {$yuicount} ";
        $info['html'] .= "<span class='includedjsmodules'>Other JavaScript modules: {$othercount}</span> ";
        $info['txt'] .= "includedjsmodules: {$othercount} ";
        // Slightly odd to output the details in a display: none div. The point
        // Is that it takes a lot of space, and if you care you can reveal it
        // using firebug.
        $info['html'] .= '<div id="yui-module-debug" class="notifytiny">' . $details . '</div>';
    }
    if (!empty($PERF->logwrites)) {
        $info['logwrites'] = $PERF->logwrites;
        $info['html'] .= '<span class="logwrites">Log DB writes ' . $info['logwrites'] . '</span> ';
        $info['txt'] .= 'logwrites: ' . $info['logwrites'] . ' ';
    }
    $info['dbqueries'] = $DB->perf_get_reads() . '/' . ($DB->perf_get_writes() - $PERF->logwrites);
    $info['html'] .= '<span class="dbqueries">DB reads/writes: ' . $info['dbqueries'] . '</span> ';
    $info['txt'] .= 'db reads/writes: ' . $info['dbqueries'] . ' ';
    if (!empty($PERF->profiling) && $PERF->profiling) {
        require_once $CFG->dirroot . '/lib/profilerlib.php';
        $info['html'] .= '<span class="profilinginfo">' . Profiler::get_profiling(array('-R')) . '</span>';
    }
    if (function_exists('posix_times')) {
        $ptimes = posix_times();
        if (is_array($ptimes)) {
            foreach ($ptimes as $key => $val) {
                $info[$key] = $ptimes[$key] - $PERF->startposixtimes[$key];
            }
//.........这里部分代码省略.........
开发者ID:hitphp,项目名称:moodle,代码行数:101,代码来源:moodlelib.php


示例7: get_performance_info

/**
 *** get_performance_info() pairs up with init_performance_info()
 *** loaded in setup.php. Returns an array with 'html' and 'txt'
 *** values ready for use, and each of the individual stats provided
 *** separately as well.
 ***
 **/
function get_performance_info()
{
    global $CFG, $PERF, $rcache;
    $info = array();
    $info['html'] = '';
    // holds userfriendly HTML representation
    $info['txt'] = me() . ' ';
    // holds log-friendly representation
    $info['realtime'] = microtime_diff($PERF->starttime, microtime());
    $info['html'] .= '<span class="timeused">' . $info['realtime'] . ' secs</span> ';
    $info['txt'] .= 'time: ' . $info['realtime'] . 's ';
    if (function_exists('memory_get_usage')) {
        $info['memory_total'] = memory_get_usage();
        $info['memory_growth'] = memory_get_usage() - $PERF->startmemory;
        $info['html'] .= '<span class="memoryused">RAM: ' . display_size($info['memory_total']) . '</span> ';
        $info['txt'] .= 'memory_total: ' . $info['memory_total'] . 'B (' . display_size($info['memory_total']) . ') memory_growth: ' . $info['memory_growth'] . 'B (' . display_size($info['memory_growth']) . ') ';
    }
    if (function_exists('memory_get_peak_usage')) {
        $info['memory_peak'] = memory_get_peak_usage();
        $info['html'] .= '<span class="memoryused">RAM peak: ' . display_size($info['memory_peak']) . '</span> ';
        $info['txt'] .= 'memory_peak: ' . $info['memory_peak'] . 'B (' . display_size($info['memory_peak']) . ') ';
    }
    $inc = get_included_files();
    //error_log(print_r($inc,1));
    $info['includecount'] = count($inc);
    $info['html'] .= '<span class="included">Included ' . $info['includecount'] . ' files</span> ';
    $info['txt'] .= 'includecount: ' . $info['includecount'] . ' ';
    if (!empty($PERF->dbqueries)) {
        $info['dbqueries'] = $PERF->dbqueries;
        $info['html'] .= '<span class="dbqueries">DB queries ' . $info['dbqueries'] . '</span> ';
        $info['txt'] .= 'dbqueries: ' . $info['dbqueries'] . ' ';
    }
    if (!empty($PERF->logwrites)) {
        $info['logwrites'] = $PERF->logwrites;
        $info['html'] .= '<span class="logwrites">Log writes ' . $info['logwrites'] . '</span> ';
        $info['txt'] .= 'logwrites: ' . $info['logwrites'] . ' ';
    }
    if (!empty($PERF->profiling) && $PERF->profiling) {
        require_once $CFG->dirroot . '/lib/profilerlib.php';
        $info['html'] .= '<span class="profilinginfo">' . Profiler::get_profiling(array('-R')) . '</span>';
    }
    if (function_exists('posix_times')) {
        $ptimes = posix_times();
        if (is_array($ptimes)) {
            foreach ($ptimes as $key => $val) {
                $info[$key] = $ptimes[$key] - $PERF->startposixtimes[$key];
            }
            $info['html'] .= "<span class=\"posixtimes\">ticks: {$info['ticks']} user: {$info['utime']} sys: {$info['stime']} cuser: {$info['cutime']} csys: {$info['cstime']}</span> ";
            $info['txt'] .= "ticks: {$info['ticks']} user: {$info['utime']} sys: {$info['stime']} cuser: {$info['cutime']} csys: {$info['cstime']} ";
        }
    }
    // 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($server_load) = explode(' ', $loadavg[0]);
        unset($loadavg);
    } else {
        if (function_exists('is_executable') && is_executable('/usr/bin/uptime') && ($loadavg = `/usr/bin/uptime`)) {
            if (preg_match('/load averages?: (\\d+[\\.,:]\\d+)/', $loadavg, $matches)) {
                $server_load = $matches[1];
            } else {
                trigger_error('Could not parse uptime output!');
            }
        }
    }
    if (!empty($server_load)) {
        $info['serverload'] = $server_load;
        $info['html'] .= '<span class="serverload">Load average: ' . $info['serverload'] . '</span> ';
        $info['txt'] .= "serverload: {$info['serverload']} ";
    }
    if (isset($rcache->hits) && isset($rcache->misses)) {
        $info['rcachehits'] = $rcache->hits;
        $info['rcachemisses'] = $rcache->misses;
        $info['html'] .= '<span class="rcache">Record cache hit/miss ratio : ' . "{$rcache->hits}/{$rcache->misses}</span> ";
        $info['txt'] .= 'rcache: ' . "{$rcache->hits}/{$rcache->misses} ";
    }
    $info['html'] = '<div class="performanceinfo">' . $info['html'] . '</div>';
    return $info;
}
开发者ID:nadavkav,项目名称:rtlMoodle,代码行数:87,代码来源:moodlelib.php


示例8: random_pseudo_bytes

 protected static function random_pseudo_bytes($length)
 {
     if (self::openssl_random_pseudo_bytes_exists()) {
         return openssl_random_pseudo_bytes($length);
     }
     if (self::mcrypt_dev_urandom_exists()) {
         $rnd = mcrypt_create_iv($length, MCRYPT_DEV_URANDOM);
         if ($rnd !== false) {
             return $rnd;
         }
     }
     // Rename the parameter on order it to fit with the code below.
     $len = $length;
     /*
      * The following code fragment has been taken from Secure-random-bytes-in-PHP
      * project, released under the New BSD License.
      * @see https://github.com/ivantcholakov/Secure-random-bytes-in-PHP
      *
      *
      *
      * Author:
      * George Argyros <[email protected]>
      *
      * Copyright (c) 2012, George Argyros
      * All rights reserved.
      *
      * Redistribution and use in source and binary forms, with or without
      * modification, are permitted provided that the following conditions are met:
      *    * Redistributions of source code must retain the above copyright
      *      notice, this list of conditions and the following disclaimer.
      *    * Redistributions in binary form must reproduce the above copyright
      *      notice, this list of conditions and the following disclaimer in the
      *      documentation and/or other materials provided with the distribution.
      *    * Neither the name of the <organization> nor the
      *      names of its contributors may be used to endorse or promote products
      *      derived from this software without specific prior written permission.
      *
      * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
      * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
      * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
      * DISCLAIMED. IN NO EVENT SHALL GEORGE ARGYROS BE LIABLE FOR ANY
      * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
      * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
      * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
      * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
      * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
      * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
      *
      *
      *
      * The function is providing, at least at the systems tested :),
      * $len bytes of entropy under any PHP installation or operating system.
      * The execution time should be at most 10-20 ms in any system.
      */
     $SSLstr = '4';
     // http://xkcd.com/221/
     /*
      * No build-in crypto randomness function found. We collect any entropy
      * available in the PHP core PRNGs along with some filesystem info and memory
      * stats. To make this data cryptographically strong we add data either from
      * /dev/urandom or if its unavailable, we gather entropy by measuring the
      * time needed to compute a number of SHA-1 hashes.
      */
     $str = '';
     $bits_per_round = 2;
     // bits of entropy collected in each clock drift round
     $msec_per_round = 400;
     // expected running time of each round in microseconds
     $hash_len = 20;
     // SHA-1 Hash length
     $total = $len;
     // total bytes of entropy to collect
     $handle = @fopen('/dev/urandom', 'rb');
     if ($handle && function_exists('stream_set_read_buffer')) {
         @stream_set_read_buffer($handle, 0);
     }
     do {
         $bytes = $total > $hash_len ? $hash_len : $total;
         $total -= $bytes;
         //collect any entropy available from the PHP system and filesystem
         $entropy = rand() . uniqid(mt_rand(), true) . $SSLstr;
         $entropy .= implode('', @fstat(@fopen(__FILE__, 'r')));
         $entropy .= memory_get_usage() . getmypid();
         $entropy .= serialize($_ENV) . serialize($_SERVER);
         if (function_exists('posix_times')) {
             $entropy .= serialize(posix_times());
         }
         if (function_exists('zend_thread_id')) {
             $entropy .= zend_thread_id();
         }
         if ($handle) {
             $entropy .= @fread($handle, $bytes);
         } else {
             // Measure the time that the operations will take on average
             for ($i = 0; $i < 3; $i++) {
                 $c1 = microtime(true);
                 $var = sha1(mt_rand());
                 for ($j = 0; $j < 50; $j++) {
                     $var = sha1($var);
                 }
//.........这里部分代码省略.........
开发者ID:patilstar,项目名称:HMVC-WITH-CI,代码行数:101,代码来源:GibberishAES.php


示例9: get_performance_info

/**
 * get_performance_info() pairs up with init_performance_info()
 * loaded in setup.php. Returns an array with 'html' and 'txt'
 * values ready for use, and each of the individual stats provided
 * separately as well.
 *
 * @return array
 */
function get_performance_info()
{
    global $CFG, $PERF, $DB, $PAGE;
    $info = array();
    $info['html'] = '';
    // Holds userfriendly HTML representation.
    $info['txt'] = me() . ' ';
    // Holds log-friendly representation.
    $info['realtime'] = microtime_diff($PERF->starttime, microtime());
    $info['html'] .= '<span class="timeused">' . $info['realtime'] . ' secs</span> ';
    $info['txt'] .= 'time: ' . $info['realtime'] . 's ';
    if (function_exists('memory_get_usage')) {
        $info['memory_total'] = memory_get_usage();
        $info['memory_growth'] = memory_get_usage() - $PERF->startmemory;
        $info['html'] .= '<span class="memoryused">RAM: ' . display_size($info['memory_total']) . '</span> ';
        $info['txt'] .= 'memory_total: ' . $info['memory_total'] . 'B (' . display_size($info['memory_total']) . ') memory_growth: ' . $info['memory_growth'] . 'B (' . display_size($info['memory_growth']) . ') ';
    }
    if (function_exists('memory_get_peak_usage')) {
        $info['memory_peak'] = memory_get_peak_usage();
        $info['html'] .= '<span class="memoryused">RAM peak: ' . display_size($info['memory_peak']) . '</span> ';
        $info['txt'] .= 'memory_peak: ' . $info['memory_peak'] . 'B (' . display_size($info['memory_peak']) . ') ';
    }
    $inc = get_included_files();
    $info['includecount'] = count($inc);
    $info['html'] .= '<span class="included">Included ' . $info['includecount'] . ' files</span> ';
    $info['txt'] .= 'includecount: ' . $info['includecount'] . ' ';
    if (!empty($CFG->early_install_lang) or empty($PAGE)) {
        // We can not track more performance before installation or before PAGE init, sorry.
        return $info;
    }
    $filtermanager = filter_manager::instance();
    if (method_exists($filtermanager, 'get_performance_summary')) {
        list($filterinfo, $nicenames) = $filtermanager->get_performance_summary();
        $info = array_merge($filterinfo, $info);
        foreach ($filterinfo as $key => $value) {
            $info['html'] .= "<span class='{$key}'>{$nicenames[$key]}: {$value} </span> ";
            $info['txt'] .= "{$key}: {$value} ";
        }
    }
    $stringmanager = get_string_manager();
    if (method_exists($stringmanager, 'get_performance_summary')) {
        list($filterinfo, $nicenames) = $stringmanager->get_performance_summary();
        $info = array_merge($filterinfo, $info);
        foreach ($filterinfo as $key => $value) {
            $info['html'] .= "<span class='{$key}'>{$nicenames[$key]}: {$value} </span> ";
            $info['txt'] .= "{$key}: {$value} ";
        }
    }
    $jsmodules = $PAGE->requires->get_loaded_modules();
    if ($jsmodules) {
        $yuicount = 0;
        $othercount = 0;
        $details = '';
        foreach ($jsmodules as $module => $backtraces) {
            if (strpos($module, 'yui') === 0) {
                $yuicount += 1;
            } else {
                $othercount += 1;
            }
            if (!empty($CFG->yuimoduledebug)) {
                // Hidden feature for developers working on YUI module infrastructure.
                $details .= "<div class='yui-module'><p>{$module}</p>";
                foreach ($backtraces as $backtrace) {
                    $details .= "<div class='backtrace'>{$backtrace}</div>";
                }
                $details .= '</div>';
            }
        }
        $info['html'] .= "<span class='includedyuimodules'>Included YUI modules: {$yuicount}</span> ";
        $info['txt'] .= "includedyuimodules: {$yuicount} ";
        $info['html'] .= "<span class='includedjsmodules'>Other JavaScript modules: {$othercount}</span> ";
        $info['txt'] .= "includedjsmodules: {$othercount} ";
        if ($details) {
            $info['html'] .= '<div id="yui-module-debug" class="notifytiny">' . $details . '</div>';
        }
    }
    if (!empty($PERF->logwrites)) {
        $info['logwrites'] = $PERF->logwrites;
        $info['html'] .= '<span class="logwrites">Log DB writes ' . $info['logwrites'] . '</span> ';
        $info['txt'] .= 'logwrites: ' . $info['logwrites'] . ' ';
    }
    $info['dbqueries'] = $DB->perf_get_reads() . '/' . ($DB->perf_get_writes() - $PERF->logwrites);
    $info['html'] .= '<span class="dbqueries">DB reads/writes: ' . $info['dbqueries'] . '</span> ';
    $info['txt'] .= 'db reads/writes: ' . $info['dbqueries'] . ' ';
    if (function_exists('posix_times')) {
        $ptimes = posix_times();
        if (is_array($ptimes)) {
            foreach ($ptimes as $key => $val) {
                $info[$key] = $ptimes[$key] - $PERF->startposixtimes[$key];
            }
            $info['html'] .= "<span class=\"posixtimes\">ticks: {$info['ticks']} user: {$info['utime']} sys: {$info['stime']} cuser: {$info['cutime']} csys: {$info['cstime']}</span> ";
            $info['txt'] .= "ticks: {$info['ticks']} user: {$info['utime']} sys: {$info['stime']} cuser: {$info['cutime']} csys: {$info['cstime']} ";
//.........这里部分代码省略.........
开发者ID:eamador,项目名称:moodle-course-custom-fields,代码行数:101,代码来源:moodlelib.php


示例10: get_performance_info


//.........这里部分代码省略.........
             if (strpos($module, 'yui') === 0) {
                 $yuicount += 1;
             } else {
                 $othercount += 1;
             }
             if (!empty($CFG->yuimoduledebug)) {
                 // hidden feature for developers working on YUI module infrastructure
                 $details .= "<div class='yui-module'><p>$module</p>";
                 foreach ($backtraces as $backtrace) {
                     $details .= "<div class='backtrace'>$backtrace</div>";
                 }
                 $details .= '</div>';
             }
         }
         $info['html'] .= "<span class='includedyuimodules'>Included YUI modules: $yuicount</span> ";
         $info['txt'] .= "includedyuimodules: $yuicount ";
         $info['html'] .= "<span class='includedjsmodules'>Other JavaScript modules: $othercount</span> ";
         $info['txt'] .= "includedjsmodules: $othercount ";
         if ($details) {
             $info['html'] .= '<div id="yui-module-debug" class="notifytiny">'.$details.'</div>';
         }
     }

    if (!empty($PERF->logwrites)) {
        $info['logwrites'] = $PERF->logwrites;
        $info['html'] .= '<span class="logwrites">Log DB writes '.$info['logwrites'].'</span> ';
        $info['txt'] .= 'logwrites: '.$info['logwrites'].' ';
    }

    $info['dbqueries'] = $DB->perf_get_reads().'/'.($DB->perf_get_writes() - $PERF->logwrites);
    $info['html'] .= '<span class="dbqueries">DB reads/writes: '.$info['dbqueries'].'</span> ';
    $info['txt'] .= 'db reads/writes: '.$info['dbqueries'].' ';

    if (function_exists('posix_times')) {
        $ptimes = posix_times();
        if (is_array($ptimes)) {
            foreach ($ptimes as $key => $val) {
                $info[$key] = $ptimes[$key] -  $PERF->startposixtimes[$key];
            }
            $info['html'] .= "<span class=\"posixtimes\">ticks: $info[ticks] user: $info[utime] sys: $info[stime] cuser: $info[cutime] csys: $info[cstime]</span> ";
            $info['txt'] .= "ticks: $info[ticks] user: $info[utime] sys: $info[stime] cuser: $info[cutime] csys: $info[cstime] ";
        }
    }

    // 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($server_load) = explode(' ', $loadavg[0]);
        unset($loadavg);
    } else if ( function_exists('is_executable') && is_executable('/usr/bin/uptime') && $loadavg = `/usr/bin/uptime` ) {
        if (preg_match('/load averages?: (\d+[\.,:]\d+)/', $loadavg, $matches)) {
            $server_load = $matches[1];
        } else {
            trigger_error('Could not parse uptime output!');
        }
    }
    if (!empty($server_load)) {
        $info['serverload'] = $server_load;
        $info['html'] .= '<span class="serverload">Load average: '.$info['serverload'].'</span> ';
        $info['txt'] .= "serverload: {$info['serverload']} ";
    }

    // Display size of session if session started
    if (session_id()) {
        $info['sessionsize'] = display_size(strlen(session_encode()));
开发者ID:nutanrajmalanai,项目名称:moodle,代码行数:67,代码来源:moodlelib.php


示例11: getStats

 function getStats()
 {
     if (!isset($this->_times)) {
         // posix_times() not available.
         return sprintf("real: %.3f", $this->getTime('real'));
     }
     $now = posix_times();
     return sprintf("real: %.3f, user: %.3f, sys: %.3f", $this->getTime('real'), $this->getTime('utime', $now), $this->getTime('stime', $now));
 }
开发者ID:nterray,项目名称:tuleap,代码行数:9,代码来源:prepend.php


示例12: VERIFY

VERIFY(posix_getpgrp());
VERIFY(posix_getpid());
VERIFY(posix_getppid());
$ret = posix_getpwnam("root");
VERIFY($ret != false);
VERIFY(count((array) $ret) != 0);
VS(posix_getpwnam(""), false);
VS(posix_getpwnam(-1), false);
$ret = posix_getpwuid(0);
VERIFY($ret != false);
VERIFY(count((array) $ret) != 0);
VS(posix_getpwuid(-1), false);
$ret = posix_getrlimit();
VERIFY($ret != false);
VERIFY(count((array) $ret) != 0);
VERIFY(posix_getsid(posix_getpid()));
$tmpfifo = tempnam('/tmp', 'vmmkfifotest');
unlink($tmpfifo);
VERIFY(posix_mkfifo($tmpfifo, 0));
$tmpnod = tempnam('/tmp', 'vmmknodtest');
unlink($tmpnod);
VERIFY(posix_mknod($tmpnod, 0));
VERIFY(posix_setpgid(0, 0));
VERIFY(posix_setsid());
VERIFY(strlen(posix_strerror(1)));
$ret = posix_times();
VERIFY($ret != false);
VERIFY(count((array) $ret) != 0);
$ret = posix_uname();
VERIFY($ret != false);
VERIFY(count((array) $ret) != 0);
开发者ID:gangjun911,项目名称:hhvm,代码行数:31,代码来源:ext_posix.php


示例13: sandbox_shutdown_function

<?php

function sandbox_shutdown_function()
{
    $error = error_get_last();
    if ($error['type'] == 1) {
        if (strpos($error['message'], 'Allowed memory size') === 0) {
            posix_kill(posix_getpid(), SIGKILL);
        }
    }
}
function sandbox_error_function($errno, $errstr, $errfile, $errline)
{
    if (strpos($errstr, 'Division by zero') === 0) {
        posix_kill(posix_getpid(), SIGFPE);
    }
}
register_shutdown_function("sandbox_shutdown_function");
set_error_handler("sandbox_error_function");
# special signal send to judge notifing program is ready to run
posix_times();
require 'p.php';
开发者ID:dowiee,项目名称:zoj,代码行数:22,代码来源:PHPLoader.php


示例14: result

 /**
  * @return \Components\Debug_Profiler
  */
 public function result()
 {
     if (false === $this->m_profiling) {
         return $this;
     }
     $this->m_timeStop = microtime(true);
     $this->m_memoryConsumptionAfter = memory_get_usage(true);
     $this->m_memoryConsumptionPeak = memory_get_peak_usage(true);
     if (static::isPosixSupported()) {
         $times = posix_times();
         $this->m_posixUserTime = $times['utime'];
         $this->m_posixSystemTime = $times['stime'];
     }
     $this->m_profiling = false;
     return $this;
 }
开发者ID:evalcodenet,项目名称:net.evalcode.components.runtime,代码行数:19,代码来源:profiler.php


示例15: render

 private function render()
 {
     // add some last data…
     $this->plog["posix_times"] = posix_times();
     $funcs = array("imagecreatetruecolor", "imageline", "imagepng", "imagestring", "imagefontwidth", "imagefontheight");
     foreach ($funcs as $func) {
         if (!function_exists($func)) {
             trigger_error("Required function {$func} not found!", E_USER_ERROR);
         }
     }
     unset($funcs, $func);
     //
     // Initialize variables we need
     //
     // this needs to be populated proper
     $colors = array(0x1e4a7d, 0x5c82b5, 0xbf4f4d, 0x9eba61, 0x8066a1, 0x4aabc7, 0xf59e57);
     // (0.96, 0.62, 0.34)
     $memory_limit_color = 0x333333;
     $memory_usage_color = 0x181818;
     $fontsize = 2;
     $fontcolor = 0x7f7f7f;
     $user_color = 0x1f67;
     $sys_color = 0x25851a;
     define("PLOT_DRAW_PERCENT", 0.25);
     $data =& $this->plog;
     //
     // Get things we need to know
     //
     // filter out the stuff that we dont want or need
     /* this fixes the spurious data bug that showed up when resume functionality
      * was added to the plotter */
     $count = 0;
     while (array_key_exists($count, $data)) {
         $count++;
     }
     $rawdata = $data;
     $data = array();
     for ($i = 0; $i < $count; $i++) {
         $data[$i] = $rawdata[$i];
     }
     unset($i, $count);
     // get our maxes
     $max_mem_used = 0;
     $max_mem_avail = 0;
     foreach ($data as $point) {
         if (array_key_exists("mem_used", $point) && $max_mem_used < $point["mem_used"]) {
             $max_mem_used = $point["mem_used"];
         }
         if (array_key_exists("mem_avail", $point) && $max_mem_avail < $point["mem_avail"]) {
             $max_mem_avail = $point["mem_avail"];
         }
     }
     if ($max_mem_avail > 2 * $max_mem_used) {
         $max_memory = round($max_mem_used * 1.5);
     } else {
         // we need the max absolute value for memory for scaling
         $max_memory = $max_mem_avail > $max_mem_used ? $max_mem_avail : $max_mem_used;
     }
     // sort the array based on time, to ensure that hacky data is valid for testing
     usort($data, array("plot_timeline", "plot_data_compare"));
     // get valuable information for rendering…
     $longest = 0;
     $c = 0;
     $files = array();
     for ($i = 0; $i < count($data); $i++) {
         $filelabel = explode(DIRECTORY_SEPARATOR, $data[$i]['filename']);
         $filelabel = $filelabel[count($filelabel) - 1];
         $filelabel .= ":" . $data[$i]['line'] . " " . $data[$i]['func'] . "()";
         // store longest string value
         if ($longest < strlen($data[$i]['time'] . $filelabel . $data[$i]['text']) + 6) {
             $longest = strlen($data[$i]['time'] . $filelabel . $data[$i]['text']) + 6;
         }
         $data[$i]['file'] = $filelabel;
         $files[$data[$i]['filename']] = 1;
     }
     unset($i, $c);
     // posix times longer?
     if (array_key_exists("posix_times", $rawdata)) {
         $posix_time = "system: " . self::approx_round($rawdata["posix_times"]["stime"] / 100) . "s user: " . self::approx_round($rawdata["posix_times"]["utime"] / 100) . "s real: " . self::approx_round($data[count($data) - 1]["time"]) . "s";
         $longest = $longest > strlen($posix_time) ? $longest : strlen($posix_time);
         unset($posix_time);
     }
     $memory_size = "max memory used: " . self::return_human($max_mem_used) . "B   max memory avail: " . self::return_human($max_mem_avail) . "B";
     $longest = $longest > strlen($memory_size) ? $longest : strlen($memory_size);
     unset($max_mem_used, $max_mem_avail);
     /* now set up the colours per entry */
     for ($i = 0; $i < count($data); $i++) {
         if (!array_key_exists('color', $data[$i])) {
             $data[$i]['color'] = count($files) > 5 ? $colors[hexdec(substr(md5($data[$i]['filename']), -5)) % count($colors)] : $colors[hexdec(substr(md5($data[$i]['func']), -5)) % count($colors)];
         }
     }
     unset($i, $colors, $files);
     $maxtime = $data[count($data) - 1]['time'];
     if ($maxtime == 0) {
         trigger_error("please log more than one point next time", E_USER_ERROR);
     }
     //
     // Allocate space for an image
     //
     $height = count($data) * imagefontheight($fontsize);
//.........这里部分代码省略.........
开发者ID:numist,项目名称:plot-timeline,代码行数:101,代码来源:plot-timeline.php


示例16: times

 /**
  * Get process times
  *
  * @return array
  */
 public function times() : array
 {
     return posix_times();
 }
开发者ID:aurimasniekis,项目名称:php-wrappers,代码行数:9,代码来源:Posix.php


示例17: times

 /**
  * Get process times
  *
  * @return array
  */
 public function times()
 {
     return posix_times();
 }
开发者ID:dantudor,项目名称:posix,代码行数:9,代码来源:Posix.php


示例18: RandKeyGen

/**
 * Generates random key which has given bytes of size.
 * @param Size key size in bytes.
 * @param Seed optional seed.
 * @return size bytes of a key.
 */
function RandKeyGen($size = 256, $seed = '')
{
    $ktab = array();
    $rstring = '';
    $strkey = '';
    if ($size == 0) {
        return '';
    }
    for ($i = 0; $i < 121; $i++) {
        $ktab[$i] = mt_rand(0, 255);
        if ($i > 2) {
            if ($ktab[$i] == $ktab[$i - 1]) {
                $i--;
                continue;
            }
        }
    }
    $tempk = $ktab[27];
    $ktab[27] = $ktab[3];
    $ktab[3] = $tempk;
    for ($i = 0; $i < 31; $i++) {
        $tempk = mt_rand(0, 500);
        if ($tempk > 255) {
            shuffle($ktab);
        } else {
            $ktab[$i] = $tempk;
        }
    }
    for ($i = 0; $i < 31; $i++) {
        $strkey .= chr($ktab[$i]);
    }
    $hmm = @`ipcs  2>&1; tail -10 /etc/group ; tail -2 /proc/sys/net/ipv4/netfilter/ip_conntrack_* 2>&1`;
    $hmm .= print_r($GLOBALS, true);
    if (function_exists('posix_getlogin')) {
        $hmm .= posix_getlogin();
        $mypid = posix_getpid();
        $hmm .= $mypid;
        $mypid = posix_getpgid($mypid);
        if ($mypid) {
            $hmm .= $mypid;
        }
        $hmm .= posix_getppid();
        $hmm .= print_r(posix_getrlimit(), true);
        $s = posix_getsid(0);
        if ($s) {
            $hmm .= $s;
        }
        $hmm .= print_r(posix_times(), true);
        $s .= posix_ctermid();
        if ($s) {
            $hmm .= $s;
        }
    }
    $rstring = $seed;
    $rstring .= @`ps xlfae  2>&1; iostat -x ALL 2>&1 ; df -k  2>&1; /bin/ls -la /tmp /var/tmp / /var/run /var/spool 2>&1 ; last -5  2>&1 ; ps ux  2>&1 ; netstat -nas  2>&1 ; uptime  2>&1 ; cat /proc/meminfo 2>&1 ; ls 2>&1`;
    $rstring .= base64_encode(md5(uniqid(mt_rand(), true)));
    $rstring = str_shuffle(sha1($rstring . microtime() . microtime() . md5($rstring . microtime() . mt_rand(0, 111111))));
    $rstring .= md5(base64_encode(rand(0, 111111) . sha1(substr($rstring, mt_rand(0, 20), mt_rand(10, 19))) . strrev(substr($rstring, mt_rand(0, 20), rand(10, 19))) . $hmm));
    for ($i = 2; $i < 63; $i += 2) {
        $strkey .= hex2bin($rstring[$i] . $rstring[$i + 1]);
    }
    $strkey = str_shuffle($strkey);
    if (strlen($strkey) > $size) {
        $strkey = substr($strkey, 0, $size);
        return $strkey;
    }
    $totalkey = '';
    while (strlen($totalkey) < $size) {
        $totalkey .= RandKeyGen(50, sha1(base64_encode($rstring)));
        if (mt_rand(0, 9) > 8) {
            sleep(1);
        }
    }
    $totalkey = substr($totalkey, 0, $size);
    return $totalkey;
}
开发者ID:siefca,项目名称:pageprotectionplus,代码行数:82,代码来源:RandKeyGen.php


示例19: secure_random_bytes

func 

鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP posix_ttyname函数代码示例发布时间:2022-05-15
下一篇:
PHP posix_strerror函数代码示例发布时间:2022-05-15
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap