当前位置: 首页>>代码示例>>PHP>>正文


PHP gettimeofday函数代码示例

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


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

示例1: sql_query

function sql_query($query)
{
    global $_auth, $_SQLUser, $_SQLArray, $_SQLCount, $_SQLTime, $_SQLCalc, $_SQLLog, $_SQLLastQuery;
    if ($_SQLCalc) {
        $time_start = gettimeofday();
    }
    $_SQLLastQuery = $query;
    $result = mysql_query($query) or fatal_error(mysql_error());
    if ($_SQLCalc) {
        $time_end = gettimeofday();
        $secdiff = $time_end["sec"] - $time_start["sec"];
        $usecdiff = $time_end["usec"] - $time_start["usec"];
        $timeF = ($secdiff * 1000000 + $usecdiff) / 1000000;
        $_SQLCount++;
        $_SQLTime += $timeF;
    }
    if ($_SQLLog) {
        if (preg_match('/^SELECT\\sCOUNT\\(\\*\\)\\sFROM/', $query)) {
            $numRows = is_resource($result) ? "=" . mysql_result($result, 0) : "-";
        } else {
            $numRows = is_resource($result) ? mysql_num_rows($result) : "-";
        }
        while (strlen($numRows) < 5) {
            $numRows = " " . $numRows;
        }
        $_SQLArray[] = array("time" => $timeF, "rows" => $numRows, "query" => $query);
    }
    return $result;
}
开发者ID:brocococonut,项目名称:yGallery,代码行数:29,代码来源:sqlwrapper.php

示例2: setUp

 public function setUp()
 {
     parent::setUp();
     // Setup container names array (list of container names used by
     // integration tests)
     self::$testQueues = array();
     for ($i = 0; $i < 10; $i++) {
         self::$testQueues[$i] = self::$testQueuesPrefix . round(gettimeofday(true)) . ($i + 1);
     }
     self::$creatableQueues = array();
     for ($i = 0; $i < 3; $i++) {
         self::$creatableQueues[$i] = self::$createableQueuesPrefix . ($i + 1);
     }
     self::$TEST_QUEUE_FOR_MESSAGES = self::$testQueues[0];
     self::$TEST_QUEUE_FOR_MESSAGES_2 = self::$testQueues[1];
     self::$TEST_QUEUE_FOR_MESSAGES_3 = self::$testQueues[2];
     self::$TEST_QUEUE_FOR_MESSAGES_4 = self::$testQueues[3];
     self::$TEST_QUEUE_FOR_MESSAGES_5 = self::$testQueues[4];
     self::$TEST_QUEUE_FOR_MESSAGES_6 = self::$testQueues[5];
     self::$TEST_QUEUE_FOR_MESSAGES_7 = self::$testQueues[6];
     self::$TEST_QUEUE_FOR_MESSAGES_8 = self::$testQueues[7];
     self::$CREATABLE_QUEUE_1 = self::$creatableQueues[0];
     self::$CREATABLE_QUEUE_2 = self::$creatableQueues[1];
     self::$CREATABLE_QUEUE_3 = self::$creatableQueues[2];
     // Create all test containers and their content
     self::createQueues(self::$testQueuesPrefix, self::$testQueues);
 }
开发者ID:rdohms,项目名称:azure-sdk-for-php,代码行数:27,代码来源:QueueServiceIntegrationTest.php

示例3: get_secs

function get_secs()
{
    global $start_secs;
    $arr = gettimeofday();
    $now = $arr['sec'] + $arr['usec'] / 1000000.0;
    return $now - $start_secs;
}
开发者ID:pacew,项目名称:couch-test,代码行数:7,代码来源:test.php

示例4: utime

/**
\sa http://php.net/manual/en/function.gettimeofday.php
\sa http://php.net/manual/en/function.microtime.php
*/
function utime($t = NULL)
{
    if (is_null($t)) {
        $t = gettimeofday(false);
    }
    return sprintf('%d.%06d', $t['sec'], $t['usec']);
}
开发者ID:grevutiu-gabriel,项目名称:iqatest,代码行数:11,代码来源:utime.php

示例5: ListByDate

function ListByDate($timespan = 1209600)
{
    require 'mysql.php';
    $all = mysql_query("SELECT title, filename, UNIX_TIMESTAMP(ultime), description, dir FROM descriptions ORDER BY `ultime` DESC, `filename` ASC");
    mysql_close($con);
    $TWO_WEEKS = 1209600;
    $SPAN = 1.5 * $TWO_WEEKS;
    $time = gettimeofday();
    $currentTime = (int) $time[sec];
    $n = 0;
    while ($row = mysql_fetch_array($all)) {
        $ultime = (int) $row['UNIX_TIMESTAMP(ultime)'];
        //echo 'Current Time = '.$currentTime.' seconds';
        $elapsedTime = $currentTime - $ultime;
        //echo 'Elapsed Time = '.$elapsedTime.' seconds';
        if ($elapsedTime < $SPAN) {
            $newShiurim['title'][$n] = $row['title'];
            $newShiurim['filename'][$n] = $row['filename'];
            $newShiurim['dir'][$n] = $row['dir'];
            $newShiurim['date'][$n] = $ultime;
            $newShiurim['description'][$n] = $row['description'];
            $n++;
        }
    }
    $sharedDate = $newShiurim['date'][0];
    printHeadline('New classes uploaded on ' . date("l F j, Y", $sharedDate));
    for ($i = 0; $i < sizeof($newShiurim['dir']); $i++) {
        if ($newShiurim['date'][$i] != $sharedDate) {
            $sharedDate = $newShiurim['date'][$i];
            printNewHeadline('New classes uploaded on ' . date("l F j, Y", $sharedDate));
        }
        printShiur($newShiurim['title'][$i], $newShiurim['filename'][$i], $newShiurim['description'][$i], $newShiurim['dir'][$i]);
    }
    //echo '<br />';
}
开发者ID:bradleytrager,项目名称:bais-mordechai-legacy,代码行数:35,代码来源:printDL.php

示例6: Draw

 function Draw()
 {
     $barCount = 6;
     $t = (gettimeofday(true) - $this->startTime) * 1000;
     $this->Clear();
     $this->setColorAnsi(AnsiColor::WHITE, AnsiColor::BLACK);
     for ($i = 0; $i < $barCount; $i++) {
         $v = (sin($t / 500.0 + 1.0 * $i / $barCount) + 1) / 2 * $this->getHeight();
         $p1_x = 0;
         $p1_y = intval($v);
         $p2_x = $this->getWidth() - 1;
         $p2_y = intval($v);
         $this->setColorAnsi($i + 9, AnsiColor::BLACK);
         /* drawLine is already clipped, we don't care about overflows */
         $this->drawLine($p1_x + 0, $p1_y - 2, $p2_x + 0, $p2_y - 2, ord('-'));
         $this->drawLine($p1_x + 0, $p1_y - 1, $p2_x + 0, $p2_y - 1, ord('*'));
         $this->drawLine($p1_x, $p1_y, $p2_x, $p2_y, ord('#'));
         $this->drawLine($p1_x + 0, $p1_y + 1, $p2_x + 0, $p2_y + 1, ord('*'));
         $this->drawLine($p1_x + 0, $p1_y + 2, $p2_x + 0, $p2_y + 2, ord('-'));
     }
     $w = $this->getWidth();
     $h = $this->getHeight();
     $x = intval($t / 10 % (12 * $w));
     $y = intval($h * (2.0 + sin($t / 200.0)) / 4);
     $this->d->bitmap($this, -$x, $h / 2 - $y, $w * 12, $y * 2);
     $this->d->bitmap($this, 12 * $w - $x, $h / 2 - $y, $w * 12, $y * 2);
     $this->setColorAnsi(AnsiColor::WHITE, AnsiColor::BLUE);
     $this->putStr($this->getWidth() - 30, $this->getHeight() - 2, " -=[ Powered by libcaca ]=- ");
     $this->setColorAnsi(AnsiColor::WHITE, AnsiColor::BLACK);
 }
开发者ID:dns,项目名称:libcaca,代码行数:30,代码来源:test.php

示例7: generateMtid

 function generateMtid()
 {
     $time = gettimeofday();
     $mtid = $time['sec'];
     $mtid .= $time['usec'];
     return $mtid;
 }
开发者ID:grlf,项目名称:eyedock,代码行数:7,代码来源:paysafecard.php

示例8: debugHelper

 public function debugHelper()
 {
     echo "<pre>";
     echo "<b>Kajona V4 Debug Subsystem</b>\n\n";
     if (getGet("debugfile") != "") {
         echo "Loading path for " . getGet("debugfile") . "\n";
         $strPath = array_search(getGet("debugfile"), class_resourceloader::getInstance()->getFolderContent("/debug", array(".php")));
         if ($strPath !== false) {
             echo "Passing request to " . $strPath . "\n\n";
             include _realpath_ . $strPath;
         }
     } else {
         echo "Searching for debug-scripts available...\n";
         $arrFiles = class_resourceloader::getInstance()->getFolderContent("/debug", array(".php"));
         echo "<ul>";
         foreach ($arrFiles as $strPath => $strOneFile) {
             echo "<li><a href='?debugfile=" . $strOneFile . "' >" . $strOneFile . "</a> <br />" . $strPath . "</li>";
         }
         echo "</ul>";
     }
     $arrTimestampEnde = gettimeofday();
     $intTimeUsed = ($arrTimestampEnde['sec'] * 1000000 + $arrTimestampEnde['usec'] - ($this->arrTimestampStart['sec'] * 1000000 + $this->arrTimestampStart['usec'])) / 1000000;
     echo "\n\n<b>PHP-Time:</b>                              " . number_format($intTimeUsed, 6) . " sec \n";
     echo "<b>Queries db/cachesize/cached/fired:</b>     " . class_carrier::getInstance()->getObjDB()->getNumber() . "/" . class_carrier::getInstance()->getObjDB()->getCacheSize() . "/" . class_carrier::getInstance()->getObjDB()->getNumberCache() . "/" . (class_carrier::getInstance()->getObjDB()->getNumber() - class_carrier::getInstance()->getObjDB()->getNumberCache()) . "\n";
     echo "<b>Templates cached:</b>                      " . class_carrier::getInstance()->getObjTemplate()->getNumberCacheSize() . " \n";
     echo "<b>Memory/Max Memory:</b>                     " . bytesToString(memory_get_usage()) . "/" . bytesToString(memory_get_peak_usage()) . " \n";
     echo "<b>Classes Loaded:</b>                        " . class_classloader::getInstance()->getIntNumberOfClassesLoaded() . " \n";
     echo "<b>Cache requests/hits/saves/cachesize:</b>   " . class_cache::getIntRequests() . "/" . class_cache::getIntHits() . "/" . class_cache::getIntSaves() . "/" . class_cache::getIntCachesize() . " \n";
     echo "</pre>";
 }
开发者ID:jinshana,项目名称:kajonacms,代码行数:30,代码来源:debug.php

示例9: xanth_init

/**
* Init function
* @ingroup Core
*/
function xanth_init()
{
    global $start_time;
    $start_time = gettimeofday(TRUE);
    ob_start();
    xanth_db_query_reset_count();
    set_error_handler('xanth_php_error_handler');
    xanth_db_connect(xanth_conf_get('db_host', ''), xanth_conf_get('db_name', ''), xanth_conf_get('db_user', ''), xanth_conf_get('db_pass', ''), xanth_conf_get('db_port', ''));
    session_set_save_handler("on_session_start", "on_session_end", "on_session_read", "on_session_write", "on_session_destroy", "on_session_gc");
    session_start();
    xComponent::init_all();
    xModule::init_all();
    //xTheme::find_default()->init();
    xanth_invoke_multi_hook(MULTI_HOOK_PAGE_CREATE_EVT, NULL);
    xanth_invoke_mono_hook(MONO_HOOK_PAGE_CREATE, NULL);
    //print log
    echo '<br />';
    echo '<br />';
    echo '<br />';
    echo '<br />';
    echo '<br />';
    foreach (xanth_get_screen_log() as $entry) {
        echo '<br />' . $entry->level . ' ' . $entry->component . ' ' . $entry->message . ' ' . $entry->filename . '@' . $entry->line;
    }
    session_write_close();
    echo ob_get_clean();
}
开发者ID:BackupTheBerlios,项目名称:xanthinplus-svn,代码行数:31,代码来源:xanthin.inc.php

示例10: getCache

 public function getCache($key)
 {
     if ($this->_checkKeyMisses($key)) {
         return null;
     }
     if (is_array($this->_local_cache) && isset($this->_local_cache[$key])) {
         $cache = $this->_local_cache[$key];
         if ($cache != null) {
             return $cache;
         }
     }
     //$cache = Globals::getCache();
     $cache = $this->_memcache;
     $origin_key = $key;
     $starttime = gettimeofday(true);
     $result = $cache->load($key);
     $endtime = gettimeofday(true);
     if ($result === FALSE) {
         $this->_addKeyMisses($origin_key);
     }
     if ($this->_profiler_enable) {
         $this->_profiler->pushToCacheProfiler($origin_key, $result, $starttime, $endtime);
     }
     if ($result != null) {
         $this->syncache($key, $result);
         $result = json_decode($result, true);
     }
     $this->_local_cache[$key] = $result;
     return $result;
 }
开发者ID:utcuong3010,项目名称:vng,代码行数:30,代码来源:ZingCache.php

示例11: usleepWindows

/**
* sleeps some number of microseconds
*
* @param    string $usec the number of microseconds to sleep
* @access   public
* @deprecated
*/
function usleepWindows($usec)
{
    $start = gettimeofday();
    do {
        $stop = gettimeofday();
        $timePassed = 1000000 * ($stop['sec'] - $start['sec']) + $stop['usec'] - $start['usec'];
    } while ($timePassed < $usec);
}
开发者ID:sexseses,项目名称:meilimei_old_api,代码行数:15,代码来源:soap_client.php

示例12: AddToEmailLog

function AddToEmailLog($sMessage, $iUserID)
{
    $tSystem = gettimeofday();
    $tSec = $tSystem['sec'];
    $tUsec = str_pad($tSystem['usec'], 6, '0');
    $sSQL = "INSERT INTO email_job_log_{$iUserID} " . "SET ejl_text='" . mysql_real_escape_string($sMessage) . "', " . "    ejl_time='{$tSec}', " . "    ejl_usec='{$tUsec}'";
    RunQuery($sSQL);
}
开发者ID:dschwen,项目名称:CRM,代码行数:8,代码来源:EmailSend.php

示例13: session_regenerate_id

 function session_regenerate_id()
 {
     $tv = gettimeofday();
     $buf = sprintf("%.15s%ld%ld%0.8f", $_SERVER['REMOTE_ADDR'], $tv['sec'], $tv['usec'], php_combined_lcg() * 10);
     session_id(md5($buf));
     setcookie('PHPSESSID', session_id(), NULL, '/');
     return TRUE;
 }
开发者ID:xxx111x1,项目名称:SmartYourFood,代码行数:8,代码来源:session.php

示例14: _genAppid

 protected function _genAppid()
 {
     $time = gettimeofday();
     $time = $time['sec'] * 100 + $time['usec'];
     $rand = mt_rand(1, $time + $time);
     $id = ($time ^ $rand) & 0xffffffff;
     return floor($id / 100) * 100;
 }
开发者ID:xtzlyp,项目名称:newpi,代码行数:8,代码来源:App.php

示例15: createHash

 /**
  *  Create a hash with a timeout from a config setting based on
  *  the $name, with a salt from timeofday.  The salt probably
  *  doesn't matter much, since a couple of random numbers are used
  *  in making the hash anyway.
  *
  *  @param $hashName - The name of the hash as a form element.
  *
  *  @param $configItem - The $configItem is used to look up the hash's
  *  timeout.  If the timeout is 0, or not set, we don't create a
  *  hash and return null.
  */
 protected static function createHash($hashName, $timeout)
 {
     $hash = null;
     if ($timeout > 0) {
         require_once 'Zend/Form/Element/Hash.php';
         $hash = new Zend_Form_Element_Hash($hashName, array('decorators' => array('ViewHelper'), 'salt' => gettimeofday(), 'timeout' => $timeout));
     }
     return $hash;
 }
开发者ID:revoleers,项目名称:rewardimizer-server,代码行数:21,代码来源:Hash.php


注:本文中的gettimeofday函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。