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


PHP wfTime函数代码示例

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


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

示例1: sendRPC

 /**
  * @access private
  * @static
  */
 function sendRPC($method, $params = array())
 {
     global $mwBlockerHost, $mwBlockerPort, $mwBlockerDebug;
     $client = new XML_RPC_Client('/Blocker', $mwBlockerHost, $mwBlockerPort);
     if ($mwBlockerDebug) {
         $client->debug = true;
     }
     $rpcParams = array_map(array('MWBlocker', 'outParam'), $params);
     $message = new XML_RPC_Message($method, $rpcParams);
     wfSuppressWarnings();
     $start = wfTime();
     $result = $client->send($message);
     $delta = wfTime() - $start;
     wfRestoreWarnings();
     $debug = sprintf("MWBlocker::sendRPC for %s took %0.2fms\n", $method, $delta * 1000.0);
     wfDebug($debug);
     if ($mwBlockerDebug) {
         echo $debug;
     }
     if (!is_object($result)) {
         throw new MWException("Unknown XML-RPC error");
     } elseif ($result->faultCode()) {
         throw new MWException($result->faultCode() . ': ' . $result->faultString());
     } else {
         $value = $result->value();
         return $value->getval();
     }
 }
开发者ID:realsoc,项目名称:mediawiki-extensions,代码行数:32,代码来源:MWBlocker.php

示例2: execute

 public function execute()
 {
     if (!($this->hasOption('file') ^ $this->hasOption('dump'))) {
         $this->error("You must provide a file or dump", true);
     }
     $this->checkOptions();
     if ($this->hasOption('file')) {
         $revision = new WikiRevision();
         $revision->setText(file_get_contents($this->getOption('file')));
         $revision->setTitle(Title::newFromText(rawurldecode(basename($this->getOption('file'), '.txt'))));
         $this->handleRevision($revision);
         return;
     }
     $this->startTime = wfTime();
     if ($this->getOption('dump') == '-') {
         $source = new ImportStreamSource($this->getStdin());
     } else {
         $this->error("Sorry, I don't support dump filenames yet. Use - and provide it on stdin on the meantime.", true);
     }
     $importer = new WikiImporter($source);
     $importer->setRevisionCallback(array(&$this, 'handleRevision'));
     $this->from = $this->getOption('from', null);
     $this->count = 0;
     $importer->doImport();
     $this->conclusions();
     $delta = wfTime() - $this->startTime;
     $this->error("Done {$this->count} revisions in " . round($delta, 2) . " seconds ");
     if ($delta > 0) {
         $this->error(round($this->count / $delta, 2) . " pages/sec");
     }
     # Perform the memory_get_peak_usage() when all the other data has been output so there's no damage if it dies.
     # It is only available since 5.2.0 (since 5.2.1 if you haven't compiled with --enable-memory-limit)
     $this->error("Memory peak usage of " . memory_get_peak_usage() . " bytes\n");
 }
开发者ID:eFFemeer,项目名称:seizamcore,代码行数:34,代码来源:dumpIterator.php

示例3: testTime

 function testTime()
 {
     $start = wfTime();
     $this->assertType('float', $start);
     $end = wfTime();
     $this->assertTrue($end > $start, "Time is running backwards!");
 }
开发者ID:amjadtbssm,项目名称:website,代码行数:7,代码来源:GlobalTest.php

示例4: run

 function run()
 {
     $this->startTime = wfTime();
     $file = fopen('php://stdin', 'rt');
     $source = new ImportStreamSource($file);
     $importer = new WikiImporter($source);
     $importer->setRevisionCallback(array(&$this, 'handleRevision'));
     return $importer->doImport();
 }
开发者ID:BackupTheBerlios,项目名称:shoutwiki-svn,代码行数:9,代码来源:renderDump.php

示例5: execute

 public function execute()
 {
     $this->outputDirectory = $this->getOption('output-dir');
     $this->startTime = wfTime();
     $source = new ImportStreamSource($this->getStdin());
     $importer = new WikiImporter($source);
     $importer->setRevisionCallback(array(&$this, 'handleRevision'));
     return $importer->doImport();
 }
开发者ID:rocLv,项目名称:conference,代码行数:9,代码来源:renderDump.php

示例6: benchHooks

 /**
  * @param $trials int
  * @return string
  */
 private function benchHooks($trials = 10)
 {
     $start = wfTime();
     for ($i = 0; $i < $trials; $i++) {
         wfRunHooks('Test');
     }
     $delta = wfTime() - $start;
     $pertrial = $delta / $trials;
     return sprintf("Took %6.2fs", $pertrial);
 }
开发者ID:Tjorriemorrie,项目名称:app,代码行数:14,代码来源:benchmarkHooks.php

示例7: benchSquid

/** @todo document */
function benchSquid($urls, $trials = 1)
{
    $start = wfTime();
    for ($i = 0; $i < $trials; $i++) {
        SquidUpdate::purge($urls);
    }
    $delta = wfTime() - $start;
    $pertrial = $delta / $trials;
    $pertitle = $pertrial / count($urls);
    return sprintf("%4d titles in %6.2fms (%6.2fms each)", count($urls), $pertrial * 1000.0, $pertitle * 1000.0);
}
开发者ID:BackupTheBerlios,项目名称:shoutwiki-svn,代码行数:12,代码来源:benchmarkPurge.php

示例8: rebuildLocalizationCache

 /**
  * Update the special pages localization cache
  */
 public function rebuildLocalizationCache()
 {
     global $IP, $wgSpecialPageCacheUpdates, $wgQueryPages, $wgQueryCacheLimit, $wgDisableQueryPageUpdate;
     $dbw = wfGetDB(DB_MASTER);
     foreach ($wgSpecialPageCacheUpdates as $special => $call) {
         if (!is_callable($call)) {
             throw new \InvalidArgumentException("Uncallable function '{$call}' for special page {$special}");
         }
         $start = wfTime();
         call_user_func($call, $dbw);
         $end = wfTime();
         $this->info(sprintf("%-30s completed in %.2fs", $special, $end - $start));
         // Wait for the slave to catch up
         wfWaitForSlaves();
     }
     // This is needed to initialise $wgQueryPages
     require_once "{$IP}/includes/QueryPage.php";
     $disabledPages = $wgDisableQueryPageUpdate ? array_flip($wgDisableQueryPageUpdate) : [];
     foreach ($wgQueryPages as $page) {
         list($class, $special) = $page;
         $limit = isset($page[2]) ? $page[2] : $wgQueryCacheLimit;
         $queryPage = $this->getQueryPage($special, $class);
         if (array_key_exists($special, $disabledPages)) {
             // skip disabled pages
             $this->info(sprintf("%-30s disabled", $special));
             continue;
         }
         if (!$queryPage->isExpensive()) {
             // don't bother with cheap pages
             $this->info(sprintf("%-30s skipped", $special));
             continue;
         }
         $start = wfTime();
         $num = $queryPage->recache($limit);
         $end = wfTime();
         if ($num === false) {
             throw new \DBError($dbw, "database error");
         }
         $this->info(sprintf("%-30s updated %d rows in %.2fs", $special, $num, $end - $start));
         if (wfGetLB()->pingAll()) {
             // commit the changes if all connections are still open
             $dbw->commit();
         } else {
             // Reopen any connections that have closed
             $count = 6;
             do {
                 sleep(10);
             } while ($count-- > 0 && !wfGetLB()->pingAll());
         }
         // Wait for the slave to catch up
         wfWaitForSlaves();
     }
 }
开发者ID:yusufchang,项目名称:app,代码行数:56,代码来源:UpdateSpecialPagesTask.class.php

示例9: progress

 function progress($updated)
 {
     $this->updated += $updated;
     $this->processed++;
     if ($this->processed % 100 != 0) {
         return;
     }
     $portion = $this->processed / $this->count;
     $updateRate = $this->updated / $this->processed;
     $now = wfTime();
     $delta = $now - $this->startTime;
     $estimatedTotalTime = $delta / $portion;
     $eta = $this->startTime + $estimatedTotalTime;
     printf("%s: %6.2f%% done on %s; ETA %s [%d/%d] %.2f/sec <%.2f%% updated>\n", wfTimestamp(TS_DB, intval($now)), $portion * 100.0, $this->table, wfTimestamp(TS_DB, intval($eta)), $this->processed, $this->count, $this->processed / $delta, $updateRate * 100.0);
     flush();
 }
开发者ID:BackupTheBerlios,项目名称:shoutwiki-svn,代码行数:16,代码来源:cleanupCaps.php

示例10: execute

 public function execute()
 {
     $dbw = wfGetDB(DB_MASTER);
     $test = $dbw->tableName('test');
     $dbw->query("CREATE TABLE IF NOT EXISTS /*_*/{$test} (\n  test_id int unsigned NOT NULL PRIMARY KEY AUTO_INCREMENT,\n  text varbinary(255) NOT NULL\n);");
     $this->insertData($dbw);
     $start = wfTime();
     $this->delete($dbw);
     $end = wfTime();
     echo "Delete: " . $end - $start;
     echo "\r\n";
     $this->insertData($dbw);
     $start = wfTime();
     $this->truncate($dbw);
     $end = wfTime();
     echo "Truncate: " . $end - $start;
     echo "\r\n";
     $dbw->dropTable('test');
 }
开发者ID:Tjorriemorrie,项目名称:app,代码行数:19,代码来源:bench_delete_truncate.php

示例11: execute

 public function execute()
 {
     $this->outputDirectory = $this->getOption('output-dir');
     $this->prefix = $this->getOption('prefix', 'wiki');
     $this->startTime = wfTime();
     if ($this->hasOption('parser')) {
         global $wgParserConf;
         $wgParserConf['class'] = $this->getOption('parser');
         $this->prefix .= "-{$wgParserConf['class']}";
     }
     $source = new ImportStreamSource($this->getStdin());
     $importer = new WikiImporter($source);
     $importer->setRevisionCallback(array(&$this, 'handleRevision'));
     $importer->doImport();
     $delta = wfTime() - $this->startTime;
     $this->error("Rendered {$this->count} pages in " . round($delta, 2) . " seconds ");
     if ($delta > 0) {
         $this->error(round($this->count / $delta, 2) . " pages/sec");
     }
     $this->error("\n");
 }
开发者ID:eFFemeer,项目名称:seizamcore,代码行数:21,代码来源:renderDump.php

示例12: bench

 public function bench(array $benchs)
 {
     $bench_number = 0;
     $count = $this->getOption('count', 100);
     foreach ($benchs as $bench) {
         // handle empty args
         if (!array_key_exists('args', $bench)) {
             $bench['args'] = array();
         }
         $bench_number++;
         $start = wfTime();
         for ($i = 0; $i < $count; $i++) {
             call_user_func_array($bench['function'], $bench['args']);
         }
         $delta = wfTime() - $start;
         // function passed as a callback
         if (is_array($bench['function'])) {
             $ret = get_class($bench['function'][0]) . '->' . $bench['function'][1];
             $bench['function'] = $ret;
         }
         $this->results[$bench_number] = array('function' => $bench['function'], 'arguments' => $bench['args'], 'count' => $count, 'delta' => $delta, 'average' => $delta / $count);
     }
 }
开发者ID:GodelDesign,项目名称:Godel,代码行数:23,代码来源:Benchmarker.php

示例13: checkWords

 static function checkWords()
 {
     wfProfileIn(__METHOD__);
     $app = F::app();
     $request = $app->getGlobal('wgRequest');
     // get request params
     $lang = $request->getVal('lang', false);
     $words = explode(',', $request->getVal('words', ''));
     // benchmark
     $time = wfTime();
     $service = new SpellCheckerService($lang);
     $ret = $service->checkWords($words);
     // BugId:2570 - log statistics
     $wordsCount = count($words);
     $suggestionsCount = count($ret['suggestions']);
     // finish the benchmark
     $time = round(wfTime() - $time, 4);
     if (!empty($ret)) {
         $ret['info']['time'] = $time;
     }
     Wikia::log(__METHOD__, __LINE__, "{$wordsCount} words checked / {$suggestionsCount} suggestions / done in {$time} sec.", true);
     wfProfileOut(__METHOD__);
     return $ret;
 }
开发者ID:schwarer2006,项目名称:wikia,代码行数:24,代码来源:SpellCheckerAjax.class.php

示例14: addChunk

 /**
  * Chunked inserts: perform an insert if we've reached the chunk limit.
  * Prints a progress report with estimated completion time.
  * @param array &$chunk -- This will be emptied if an insert is done.
  * @param int $key A key identifier to use in progress estimation in
  *                 place of the number of rows inserted. Use this if
  *                 you provided a max key number instead of a count
  *                 as the final chunk number in setChunkScale()
  * @access private
  */
 function addChunk(&$chunk, $key = null)
 {
     if (count($chunk) >= $this->chunkSize) {
         $this->insertChunk($chunk);
         $this->chunkCount += count($chunk);
         $now = wfTime();
         $delta = $now - $this->chunkStartTime;
         $rate = $this->chunkCount / $delta;
         if (is_null($key)) {
             $completed = $this->chunkCount;
         } else {
             $completed = $key;
         }
         $portion = $completed / $this->chunkFinal;
         $estimatedTotalTime = $delta / $portion;
         $eta = $this->chunkStartTime + $estimatedTotalTime;
         printf("%s: %6.2f%% done on %s; ETA %s [%d/%d] %.2f/sec\n", wfTimestamp(TS_DB, intval($now)), $portion * 100.0, $this->chunkTable, wfTimestamp(TS_DB, intval($eta)), $completed, $this->chunkFinal, $rate);
         flush();
         $chunk = array();
     }
 }
开发者ID:eFFemeer,项目名称:seizamcore,代码行数:31,代码来源:upgrade1_5.php

示例15: updateWSResults

 /**
  * This method updates cache entries that are used in properties
  * that are outdated for a single webservice
  *
  */
 private function updateWSResults($ws)
 {
     $log = SGAGardeningIssuesAccess::getGardeningIssuesAccess();
     echo "updating " . $ws->getName() . "\n";
     $parameterSets = WSStorage::getDatabase()->getWSUsages($ws->getArticleID());
     $updatedEntries = 0;
     $affectedArticles = array();
     foreach ($parameterSets as $parameterSet) {
         echo "\t updating paramater set " . $parameterSet["paramSetId"] . "\n";
         $cacheResult = WSStorage::getDatabase()->getResultFromCache($ws->getArticleID(), $parameterSet["paramSetId"]);
         $refresh = false;
         if (count($cacheResult) < 1) {
             $refresh = true;
         }
         if (!$refresh) {
             if ($ws->getQueryPolicy() > 0) {
                 if (wfTime() - wfTimestamp(TS_UNIX, $cacheResult["lastUpdate"]) > $ws->getQueryPolicy() * 60) {
                     $refresh = true;
                 }
             }
         }
         if ($refresh) {
             echo "\t\t update necessary\n";
             if ($updatedEntries > 0) {
                 sleep($ws->getUpdateDelay());
                 echo "\t\t sleeping " . $ws->getUpdateDelay() . "\n";
             }
             $parameters = WSStorage::getDatabase()->getParameters($parameterSet["paramSetId"]);
             $parameters = $ws->initializeCallParameters($parameters);
             $response = $ws->getWSClient()->call($ws->getMethod(), $parameters);
             $goon = true;
             if (is_string($response)) {
                 $log->addGardeningIssueAboutValue($this->id, SMW_GARDISSUE_ERROR_WSCACHE_ENTRIES, Title::newFromText($ws->getName()), 0);
                 $goon = false;
             }
             if ($goon) {
                 WSStorage::getDatabase()->storeCacheEntry($ws->getArticleID(), $parameterSet["paramSetId"], serialize($response), wfTimeStamp(TS_MW, wfTime()), wfTimeStamp(TS_MW, wfTime()));
                 echo "\t\t update was successfully\n";
                 //get articles which have to be refreshed
             }
         }
         $tempAffectedArticles = WSStorage::getDatabase()->getUsedWSParameterSetPairs($ws->getArticleID(), $parameterSet["paramSetId"]);
         if ($ws->getQueryPolicy() > 0) {
             if ($refresh || count($tempAffectedArticles) > 1) {
                 $affectedArticles = array_merge($affectedArticles, $tempAffectedArticles);
             }
             $updatedEntries += 1;
         }
     }
     return $affectedArticles;
 }
开发者ID:seedbank,项目名称:old-repo,代码行数:56,代码来源:SMW_WSUpdateBot.php


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