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


PHP Timer::stop方法代码示例

本文整理汇总了PHP中Timer::stop方法的典型用法代码示例。如果您正苦于以下问题:PHP Timer::stop方法的具体用法?PHP Timer::stop怎么用?PHP Timer::stop使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Timer的用法示例。


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

示例1: parse

 function parse()
 {
     if ($this->doParseRSS) {
         require_once "include/domit_rss/timer.php";
         $timer = new Timer();
         $success = false;
         $timer->start();
         if (!defined('DOMIT_RSS_INCLUDE_PATH')) {
             define('DOMIT_RSS_INCLUDE_PATH', dirname(__FILE__) . "/");
         }
         switch ($this->rssparser) {
             case "domit_rss_lite":
                 require_once DOMIT_RSS_INCLUDE_PATH . 'xml_domit_rss_lite.php';
                 $this->rssdoc = new xml_domit_rss_document_lite($this->rssurl);
                 break;
             case "domit_rss":
                 require_once DOMIT_RSS_INCLUDE_PATH . 'xml_domit_rss.php';
                 $this->rssdoc = new xml_domit_rss_document($this->rssurl);
                 break;
         }
         // switch
         $timer->stop();
         $this->displayNew();
         echo "<br /><br />Time elapsed: " . $timer->getTime() . "seconds<br /><br />\n";
     }
 }
开发者ID:klr2003,项目名称:sourceread,代码行数:26,代码来源:testing_domitrss.php

示例2: testDuration

 /**
  * Tests duration measuring.
  */
 public function testDuration()
 {
     $mt = microtime(true);
     $name = Timer::start();
     $delta = Timer::stop($name);
     $outerDelta = microtime(true) - $mt;
     // Measured time is greater than 0
     $this->assertGreaterThan(0, $delta);
     // Measured time is less than the time between the two function calls
     $this->assertLessThan($outerDelta, $delta);
     // Non-existent timer
     $this->assertSame(0, Timer::stop('foo'));
     // Start 4 timers
     $names = array('foo', 'bar', 'tmp', 'ohai');
     $times = array_fill_keys($names, 0);
     foreach ($names as $name) {
         Timer::start($name);
     }
     // End them in reverse order
     foreach (array_reverse($names) as $name) {
         $times[$name] = Timer::stop($name);
     }
     // The measured time is supposed to be in descending order
     foreach ($names as $i => $name) {
         $this->assertGreaterThan(0, $times[$name]);
         if ($i > 0) {
             $this->assertLessThan($times[$names[$i - 1]], $times[$name]);
         }
     }
 }
开发者ID:JerryCR,项目名称:php-2,代码行数:33,代码来源:TimerTest.php

示例3: getSource

 public function getSource($pageID)
 {
     Timer::start('LiveFromFileCollection');
     $content = file_get_contents($this->currentArticleFile);
     Timer::stop('LiveFromFileCollection');
     return $content;
 }
开发者ID:nsystem1,项目名称:ZeeJong,代码行数:7,代码来源:LiveFromFileCollection.php

示例4: run

 public function run()
 {
     # Only run once.
     if ($this->result !== null) {
         return $this;
     }
     # It's nice to have this as an implicit condition.
     if ($this->should_except) {
         $this->conditions[] = new Condition(function ($result) {
             return $result->exception() !== null;
         }, 'should throw exception');
     } else {
         $this->conditions[] = new Condition(function ($result) {
             return $result->exception() === null;
         }, 'should not throw exception');
     }
     ob_start();
     $value = null;
     $exception = null;
     $timer = new Timer();
     try {
         $value = call_user_func($this->closure, $this);
     } catch (\Exception $e) {
         $exception = $e;
     }
     $output = ob_get_clean();
     $this->result = new Result($value, $output, $timer->stop(), $exception);
     return $this;
 }
开发者ID:maxvu,项目名称:sliver,代码行数:29,代码来源:Test.php

示例5: extractPage

 public function extractPage($pageID, $pageTitle, $pageSource)
 {
     $this->extractor->setPageURI($pageID);
     if (!$this->extractor->isActive()) {
         return $result = new ExtractionResult($pageID, $this->extractor->getLanguage(), $this->getExtractorID());
     }
     Timer::start($this->extractor->getExtractorID());
     $result = $this->extractor->extractPage($pageID, $pageTitle, $pageSource);
     Timer::stop($this->extractor->getExtractorID());
     Timer::start('validation');
     //$this->extractor->check();
     if (Options::getOption('validateExtractors')) {
         ValidateExtractionResult::validate($result, $this->extractor);
     }
     Timer::stop('validation');
     Statistics::increaseCount($this->extractor->getExtractorID(), 'created_Triples', count($result->getTriples()));
     Statistics::increaseCount('Total', 'created_Triples', count($result->getTriples()));
     if ($this->extractor->isGenerateOWLAxiomAnnotations()) {
         $triples = $result->getTriples();
         if (count($triples) > 0) {
             foreach ($triples as $triple) {
                 $triple->addDCModifiedAnnotation();
                 $triple->addExtractedByAnnotation($this->extractor->getExtractorID());
             }
         }
     }
     return $result;
 }
开发者ID:nsystem1,项目名称:ZeeJong,代码行数:28,代码来源:ExtractorContainer.php

示例6: populateCharacters

 private static function populateCharacters($db)
 {
     global $baseDir;
     $timer = new Timer();
     $maxTime = 65 * 1000;
     // Reset 222's that are over a week old
     $db->execute("update zz_api set errorCode = 0 where errorCode = 222 and lastValidation <= date_sub(now(), interval 7 day)");
     $apiCount = $db->queryField("select count(*) count from zz_api where errorCode not in (203, 220, 222) and lastValidation <= date_add(now(), interval 1 minute)", "count", array(), 0);
     if ($apiCount == 0) {
         return;
     }
     $fetchesPerSecond = 25;
     $iterationCount = 0;
     while ($timer->stop() < $maxTime) {
         $keyIDs = $db->query("select distinct keyID from zz_api where errorCode not in (203, 220, 222) and lastValidation < date_sub(now(), interval 2 hour)\r\n\t\t\t\t\torder by lastValidation, dateAdded desc limit 100", array(), 0);
         foreach ($keyIDs as $row) {
             if (Util::isMaintenanceMode()) {
                 return;
             }
             $keyID = $row["keyID"];
             $m = $iterationCount % $fetchesPerSecond;
             $db->execute("update zz_api set lastValidation = date_add(lastValidation, interval 5 minute) where keyID = :keyID", array(":keyID" => $keyID));
             $command = "flock -w 60 {$baseDir}/cache/locks/populate.{$m} php5 {$baseDir}/cli.php apiFetchCharacters " . escapeshellarg($keyID);
             //Log::log("$command");
             exec("{$command} >/dev/null 2>/dev/null &");
             $iterationCount++;
             if ($iterationCount % $fetchesPerSecond == 0) {
                 sleep(1);
             }
         }
         sleep(1);
     }
 }
开发者ID:Covert-Inferno,项目名称:zKillboard,代码行数:33,代码来源:cli_populateCharacters.php

示例7: initResource

 public static function initResource($inifile)
 {
     //Timer::start("a");
     $arr = parse_ini_file($inifile);
     /*
     		Timer::stop("a");
     		Timer::start("b");
     		$p = new Properties();
     		$fp = fopen($inifile.'2','r');
     		$p->load($fp);
     		
     		//print_r($p->propertyNames());
     		Timer::stop("b");
     		Timer::printTime(10);
     		die();
     */
     if (!is_array($arr) || !count($arr) > 0) {
         die("core/ResourcePool : inifile " . $inifile . " not found\n");
     }
     Timer::start('ResourcePool::init::' . $class);
     $class = new ReflectionClass($arr['className']);
     $resourceInstance = $class->newInstance($arr);
     $resourceInstance->init();
     self::$resources = $resourceInstance;
     Timer::stop('ResourcePool::init::' . $class);
     //$resourceInstance
     //$resourceInstance->setStatus($status);
 }
开发者ID:ljarray,项目名称:dbpedia,代码行数:28,代码来源:ResourcePool.php

示例8: elapsedTimeGreaterThanZeroUsingStartAndStop

 public function elapsedTimeGreaterThanZeroUsingStartAndStop()
 {
     $fixture = new Timer();
     $fixture->start();
     usleep(100 * 1000);
     $fixture->stop();
     $elapsed = $fixture->elapsedTime();
     $this->assertTrue($elapsed > 0.0, 'Elapsed time should be greater than zero');
 }
开发者ID:Gamepay,项目名称:xp-framework,代码行数:9,代码来源:TimerTest.class.php

示例9: showExecutionTime

 /**
  * Add execution time to response
  *
  * @return void
  */
 public static function showExecutionTime()
 {
     $time = Timer::stop();
     if (Response::$outJson) {
         Response::add(['executionTime' => $time . 'ms']);
     } else {
         Response::add("<!-- executionTime {$time}ms -->");
     }
 }
开发者ID:smith46102,项目名称:koda,代码行数:14,代码来源:timer.php

示例10: handleEnd

 /**
  * @param \CEvent $event
  * @param string $action
  */
 private function handleEnd(\CEvent $event, $action)
 {
     if ($timer = $this->popTimer($event, $action)) {
         if ($event->params) {
             Timer::dataMerge($timer, $event->params);
         }
         Timer::stop($timer);
     }
 }
开发者ID:bankiru,项目名称:yii-pinba,代码行数:13,代码来源:EventHandler.php

示例11: execute

 /**
  * Triggers the ExtractionJob
  * @param $job: An ExtractionJob
  */
 public function execute($job)
 {
     $language = $job->getPageCollection()->getLanguage();
     // Initialize Extractors and Destination
     foreach (new ArrayObject($job->getExtractionGroups()) as $group) {
         $group->getDestination()->start();
         foreach (new ArrayObject($group->getExtractors()) as $extractor) {
             $extractor->start($language);
         }
     }
     $this->log(DEBUG, "extractors started");
     // Extract content from WikiPedia Pages
     // The PageTitleIterator loops over all pages from a PageCollection
     foreach ($job->getPageTitleIterator() as $pageTitle) {
         Timer::start(get_class($job->getPageCollection()) . '::getSource');
         $pageSource = $job->getPageCollection()->getSource($pageTitle);
         Timer::stop(get_class($job->getPageCollection()) . '::getSource');
         $pageID = $this->getPageID($pageTitle, $pageSource, $language);
         if ($pageID === false || $pageID == NULL) {
             continue;
         }
         $this->log(DEBUG, "begin page extraction");
         // Extract the content and pass it to the Destination
         foreach (new ArrayObject($job->getExtractionGroups()) as $group) {
             $destination = $group->getDestination();
             foreach (new ArrayObject($group->getExtractors()) as $extractor) {
                 $this->log(DEBUG, "extractPage: " . $extractor->getExtractorID());
                 $result = $extractor->extractPage($pageID, $pageTitle, $pageSource);
                 Timer::start('destination:accept');
                 $destination->accept($result);
                 Timer::stop('destination:accept');
             }
             //end foreach
         }
         //end outer foreach
     }
     // Close Destinations and Extractors
     foreach (new ArrayObject($job->getExtractionGroups()) as $group) {
         Timer::start('destination:finish');
         $group->getDestination()->finish();
         Timer::stop('destination:finish');
         // Optional MetaInformation is stored in MetaDestination
         // Currently only used for InfoboxExtraction for predicates
         $metaDestination = $group->getMetaDestination();
         if ($metaDestination != null) {
             $metaDestination->start();
             foreach (new ArrayObject($group->getExtractors()) as $extractor) {
                 $result = $extractor->finish();
                 if ($result != null) {
                     $metaDestination->accept($result);
                 }
             }
             $metaDestination->finish();
         }
     }
 }
开发者ID:nsystem1,项目名称:ZeeJong,代码行数:60,代码来源:ExtractionManager.php

示例12: serializeLowMemory

 /**
  * Try to emulate SAX type serialization, because otherwise it goes out of memory
  * @param $data
  * @param $output Sets the output to this variable
  * @param $clear_data If set, $data is cleared once serialization is done
  * @return unknown_type
  */
 function serializeLowMemory(&$data, &$output, $clear_data = false, $batch_size = 1000)
 {
     if ($this->serializer == false) {
         $serializer_options = array('addDecl' => FALSE, 'encoding' => 'ISO-8859-1', 'indent' => '  ', 'rootName' => 'item', 'defaultTagName' => 'item');
         $this->serializer = new XML_Serializer($serializer_options);
     }
     list($temp_file_name, $http) = Util::getTemporaryFile('xml-serialize', 'xml');
     $this->logger->debug("Using temporary file for XML Serialization: {$temp_file_name}");
     $fh = fopen($temp_file_name, 'w');
     fwrite($fh, "<?xml version='1.0' encoding='ISO-8859-1'?>\n<root>\n");
     if (Util::is_assoc($data)) {
         foreach ($data as $top_level_tag_key => &$data_value) {
             $first = true;
             fwrite($fh, "<{$top_level_tag_key}>\n");
             if (is_array($data_value)) {
                 $count = 0;
                 $string = "";
                 $timer = new Timer('SerializationTimer');
                 $timer->start();
                 foreach ($data_value as $second_level_key => &$second_level_value) {
                     $string .= $this->serializeXml($second_level_value) . "\n";
                     $count++;
                     if ($count % $batch_size == 0) {
                         $timer->stop();
                         fwrite($fh, $string);
                         $string = "";
                         $this->logger->debug("{$top_level_tag_key} > Serialized upto row - " . $count++ . ". Time Taken : " . $timer->getLastLapTime() . "s. Current Memory usage: " . memory_get_usage() / 1000000 . "MB");
                         $timer->start();
                     }
                     if ($first) {
                         $this->logger->debug("{$top_level_tag_key} > XML Serialization Sample Data : Key is {$second_level_key}\nValue is " . print_r($second_level_value, true));
                         $first = false;
                     }
                     //if clear data is set, clear the second level value
                     if ($clear_data) {
                         $second_level_value = false;
                     }
                     //fflush($fh);
                 }
                 //the last batch might not be complete
                 if ($string != "") {
                     $timer->stop();
                     fwrite($fh, $string);
                     $string = "";
                 }
             }
             fwrite($fh, "</{$top_level_tag_key}>\n");
             if ($clear_data) {
                 $data_value = false;
             }
         }
     }
     fwrite($fh, "\n</root>");
     fclose($fh);
     $output = file_get_contents($temp_file_name);
 }
开发者ID:rajnishp,项目名称:bjs,代码行数:63,代码来源:Xml.php

示例13: runPlugin

 public function runPlugin($input = array())
 {
     $badContent = 1;
     $goodContent = 1;
     if (!isset($input['tracerouteFailDomain'])) {
         $input['tracerouteFailDomain'] = '';
     }
     if (!isset($input['followRedirects'])) {
         $input['followRedirects'] = 1;
     }
     $input['followRedirects'] = (bool) $input['followRedirects'];
     for ($i = $input['attempts']; $i <= $input['attempts']; $i++) {
         $output = Plugin::$output;
         ///set defaults for all output
         $t = new Timer();
         $t->start();
         $output['returnContent'] = HttpContentPlugin::doHTTPGet($input['url'], $input['maxConnectTimeoutSeconds'], $input['maxRequestTimeoutSeconds'], $input['followRedirects']);
         //			echo $output['returnContent'];
         $output['responseTimeMs'] = (int) $t->stop();
         $output['measuredValue'] = $output['returnContent'];
         if (trim($input['goodContent']) != '') {
             $goodContent = strpos($output['returnContent'], $input['goodContent']) === false ? 0 : 1;
         }
         if (trim($input['badContent']) != '') {
             $badContent = strpos($output['returnContent'], $input['badContent']) === false ? 1 : 0;
         }
         //default to down
         $output['currentStatus'] = 0;
         //if its already bad, then its bad.
         if ($goodContent + $badContent == 2) {
             $output['currentStatus'] = 1;
         }
         if ($output['currentStatus'] == 1) {
             //we've got what we wanted
             break;
         } else {
             //else keep going till we do or hit max attempts
             if (isset($input['attemptWait']) && $input['attemptWait'] !== 0) {
                 usleep($input['attemptWait'] * 1000);
             }
         }
     }
     //html email
     $output['htmlEmail'] = 1;
     if ($output['currentStatus'] == 0 && $input['tracerouteFailDomain'] != '') {
         $tmpfname = tempnam("/tmp", "phpMonitorHTTPContent");
         // do here something
         $cmd = '/usr/sbin/mtr --report --report-cycles 5 ' . $input['tracerouteFailDomain'] . ' > ' . $tmpfname . ' 2>&1';
         exec($cmd);
         $return = file_get_contents($tmpfname);
         unlink($tmpfname);
         //			echo $cmd;
         $output['returnContent'] = $output['returnContent'] . "\n\n<pre>{$return}</pre>";
     }
     return $output;
 }
开发者ID:laiello,项目名称:phpmonitoring,代码行数:56,代码来源:HttpContent.plugin.php

示例14: run

 /**
  * Run benchmark.
  *
  * @throws BenchEx
  *
  * @return Bench
  */
 public function run()
 {
     foreach ($this->benchmarks as $name => $benchmark) {
         $this->timer->start($name);
         $benchmark($this->iterations);
         $this->timer->stop($name);
     }
     $this->createSummary();
     return $this;
 }
开发者ID:rzajac,项目名称:phpbench,代码行数:17,代码来源:Bench.php

示例15: parse

 function parse()
 {
     if ($this->xmlaction != null) {
         require_once "timer.php";
         $timer = new Timer();
         $success = false;
         $this->saxparser == "saxy" ? $parseSAXY = true : ($parseSAXY = false);
         $timer->start();
         switch ($this->domparser) {
             case "domit":
                 //change this to the domit path
                 require_once 'xml_domit_parser.php';
                 $this->xmldoc =& new DOMIT_Document();
                 $this->xmldoc->expandEmptyElementTags(true);
                 $this->xmldoc->setNamespaceAwareness(true);
                 break;
             case "domitlite":
                 //change this to the domit lite path
                 require_once 'xml_domit_lite_parser.php';
                 $this->xmldoc =& new DOMIT_Lite_Document();
                 break;
         }
         // switch
         switch ($this->xmlaction) {
             case "parsefile":
                 $success = $this->xmldoc->loadXML($this->xmlfile, $parseSAXY);
                 break;
             case "parseurl":
                 $success = $this->xmldoc->loadXML("http://" . $this->xmlurl, $parseSAXY);
                 break;
             case "parsetext":
                 $success = $this->xmldoc->parseXML($this->xmltext, $parseSAXY);
                 break;
         }
         $timer->stop();
         if ($success) {
             echo "<br /><br />Time elapsed: " . $timer->getTime() . "seconds<br /><br />\n";
             if ($this->xmloutput == "tostring") {
                 echo $this->xmldoc->toString(true);
             } else {
                 if ($this->xmloutput == "tonormalizedstring") {
                     echo $this->xmldoc->toNormalizedString(true);
                 } else {
                     if ($this->xmloutput == "toarray") {
                         echo "<pre>\n";
                         print_r($this->xmldoc->toArray());
                         echo "</pre>\n";
                     }
                 }
             }
         } else {
             echo "<br /><br />Parsing error: xml document may be invalid or malformed.\n";
         }
     }
 }
开发者ID:BackupTheBerlios,项目名称:openology-svn,代码行数:55,代码来源:testing_domit.php


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