本文整理汇总了PHP中Timer::end方法的典型用法代码示例。如果您正苦于以下问题:PHP Timer::end方法的具体用法?PHP Timer::end怎么用?PHP Timer::end使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Timer
的用法示例。
在下文中一共展示了Timer::end方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testCanDetectEnd
public function testCanDetectEnd()
{
$this->assertFalse($this->timer->hasEnded([]));
$this->timer->begin([]);
$this->assertFalse($this->timer->hasEnded([]));
$this->timer->end([]);
$this->assertTrue($this->timer->hasEnded([]));
$this->timer->end(['1', 'a']);
$this->assertTrue($this->timer->hasEnded(['1', 'a']));
}
示例2: term
/**
* Calculate time since start and return plain time
* @param digits number of decimals to calculate
* @return time with microseconds since start
*/
function term($digits = null)
{
self::$end = microtime(true);
if (!preg_match("/[0-9]{1,3}/", $digits)) {
$digits = self::$digits;
}
self::$time = number_format(self::$end - self::$start, $digits);
self::$requests = number_format(1 / self::$time, self::$req_digits);
return self::$time;
}
示例3: dirname
* @package harmoni.osid_v2.agent.tests
*
* @copyright Copyright © 2005, Middlebury College
* @license http://www.gnu.org/copyleft/gpl.html GNU General Public License (GPL)
*
* @version $Id: test.php,v 1.18 2007/09/04 20:25:40 adamfranco Exp $
*/
require_once dirname(__FILE__) . "/../../../../../concerto/index.php";
require_once dirname(__FILE__) . "/../../../../core/utilities/Timer.class.php";
$timer = new Timer();
$timer->start();
$harmonyLoadupTimer = new Timer();
$harmonyLoadupTimer->start();
require_once dirname(__FILE__) . "/../../../../harmoni.inc.php";
//require_once(dirname(__FILE__)."/../../../../../concerto/main/include/setup.inc.php");
$harmonyLoadupTimer->end();
require_once SIMPLE_TEST . 'simple_unit.php';
require_once SIMPLE_TEST . 'oki_simple_unit.php';
require_once SIMPLE_TEST . 'dobo_simple_html_test.php';
/* if (!defined('CONCERTODBID')) { */
/* require_once(CONCERTO.'/tests/dbconnect.inc.php'); */
/* } */
require_once HARMONI . "errorHandler/ErrorHandler.class.php";
$errorHandler = Services::getService("ErrorHandler");
$context = new OsidContext();
$configuration = new ConfigurationProperties();
Services::startManagerAsService("DatabaseManager", $context, $configuration);
$test = new GroupTest('CourseManagementTest');
$test->addTestFile(dirname(__FILE__) . '/CanonicalCourseTestCase.class.php');
$test->addTestFile(dirname(__FILE__) . '/CourseGroupTestCase.class.php');
$test->addTestFile(dirname(__FILE__) . '/CourseOfferingTestCase.class.php');
示例4: Timer
<?php
require 'Timer.class.php';
$timer = new Timer();
$timer->start();
$timer->start('program1');
usleep(mt_rand(100000, 500000));
$timer->end('program1');
$timer->printTime('program1');
$timer->start('program2');
usleep(mt_rand(100000, 500000));
$timer->end('program2');
$timer->printTime('program2');
$timer->end();
$timer->printTime();
示例5: updateTable
//.........这里部分代码省略.........
if ($modificationDate->isGreaterThan(DateAndTime::fromString($result->field('datestamp'))) || $forceUpdate) {
// printpre("\tUpdating:\t".$asset->getDisplayName());
$query = $baseUpdateQuery->copy();
$query->addWhereEqual("oai_set", $repositoryId->getIdString());
$query->addWhereEqual("oai_identifier", $assetId->getIdString());
} else {
$query = null;
}
}
if ($query) {
$query->addRawValue('datestamp', 'NOW()');
}
$isCurrentlyDeleted = $result->getNumberOfRows() && $result->field('deleted') == 'true' ? true : false;
$result->free();
if (!count($authGroupIds)) {
$isVisible = true;
} else {
$isVisible = false;
try {
foreach ($authGroupIds as $id) {
if ($authorizationManager->isAuthorized($id, $viewId, $assetId)) {
$isVisible = true;
break;
}
}
} catch (UnknownIdException $e) {
$isVisible = true;
}
}
if ($query) {
//Add the data fields
// Deleted
if ($isVisible) {
$query->addValue('deleted', 'false');
} else {
$query->addValue('deleted', 'true');
}
$query->addValue('dc_title', $asset->getDisplayName());
$query->addValue('dc_description', $asset->getDescription());
$this->addDublinCoreValues($asset, $query);
$dbc->query($query, $config->getProperty('OAI_DBID'));
$updatesInRepository++;
$numUpdates++;
} else {
if ($isCurrentlyDeleted && $isVisible) {
$query = $baseUndeleteQuery->copy();
} else {
if (!$isCurrentlyDeleted && !$isVisible) {
$query = $baseDeleteQuery->copy();
} else {
$query = null;
}
}
if ($query) {
$query->addWhereEqual("oai_set", $repositoryId->getIdString());
$query->addWhereEqual("oai_identifier", $assetId->getIdString());
$dbc->query($query, $config->getProperty('OAI_DBID'));
$updatesInRepository++;
$numUpdates++;
}
}
$status->updateStatistics();
}
// Update any missing assets as deleted
$query = $baseDeleteQuery->copy();
$query->addWhereEqual("oai_set", $repositoryId->getIdString());
if (count($existingAssetIds)) {
$query->addWhereEqual("deleted", "false");
$query->addWhereNotIn("oai_identifier", $existingAssetIds);
}
$result = $dbc->query($query, $config->getProperty('OAI_DBID'));
if ($result->getNumberOfRows()) {
$updatesInRepository = $updatesInRepository + $result->getNumberOfRows();
$numUpdates = $numUpdates + $result->getNumberOfRows();
}
print OAI_UPDATE_OUTPUT_HTML ? "<pre>" : "\n";
print "Elapsed Time:\t";
$timer->end();
printf("%1.2f", $timer->printTime());
print " seconds";
print OAI_UPDATE_OUTPUT_HTML ? "</pre>" : "";
print OAI_UPDATE_OUTPUT_HTML ? "<pre>" : "\n";
print "Updates: " . $updatesInRepository;
print OAI_UPDATE_OUTPUT_HTML ? "</pre>" : "\n";
}
// Update any missing repositories as deleted
$query = $baseDeleteQuery->copy();
$query->addWhereEqual("deleted", "false");
if (count($existingRepositoryIds)) {
$query->addWhereNotIn("oai_set", $existingRepositoryIds);
}
$result = $dbc->query($query, $config->getProperty('OAI_DBID'));
if ($result->getNumberOfRows()) {
$updatesInRepository = $updatesInRepository + $result->getNumberOfRows();
$numUpdates = $numUpdates + $result->getNumberOfRows();
}
print OAI_UPDATE_OUTPUT_HTML ? "<pre>" : "\n";
print "Total Updates:\t" . $numUpdates;
print OAI_UPDATE_OUTPUT_HTML ? "</pre>" : "\n";
}
示例6: render_partial
render_partial('menu');
?>
</div>
<div id="content">
<?php
echo $content_for_layout;
?>
</div>
<?php
if (Timer::$started) {
?>
<div id="footer">
A Prototype App © 2010
<div id="timer">
<?php
echo Timer::end(5);
?>
<?php
echo " - " . round(memory_get_usage(true) / (1024 * 1024), 3) . " MB";
?>
</div>
</div>
<?php
}
?>
</div>
<?php
render_partial('google_analytics');
?>
</body>
</html>
示例7: Timer
require_once MYDIR . "/main/include/setup.inc.php";
/*********************************************************
* Execute our actions
*********************************************************/
if (defined('ENABLE_TIMERS') && ENABLE_TIMERS) {
require_once HARMONI . "/utilities/Timer.class.php";
$execTimer = new Timer();
$execTimer->start();
}
require_once HARMONI . "architecture/output/CommandLineOutputHandler.class.php";
$harmoni->attachOutputHandler(new CommandLineOutputHandler());
require_once HARMONI . "architecture/request/CommandLineRequestHandler.class.php";
$harmoni->request->assignRequestHandler(new CommandLineRequestHandler($_SERVER['argv']));
try {
$harmoni->execute();
} catch (UnknownActionException $e) {
print HELP_TEXT;
} catch (HelpRequestedException $e) {
print $e->getMessage();
}
if (defined('ENABLE_TIMERS') && ENABLE_TIMERS) {
$execTimer->end();
print "\n<table>\n<tr><th align='right'>Execution Time:</th>\n<td align='right'><pre>";
printf("%1.6f", $execTimer->printTime());
print "</pre></td></tr>\n</table>";
$dbhandler = Services::getService("DBHandler");
printpre("NumQueries: " . $dbhandler->getTotalNumberOfQueries());
// printpreArrayExcept($_SESSION, array('__temporarySets'));
// debug::output(session_id());
// Debug::printAll();
}
示例8: stop
/**
* Call to stop timer
* @static
*/
public static function stop()
{
self::$end = microtime(TRUE);
}
示例9: getAZs
/**
* Auxilliary private function that returns Authorizations according to a
* criteria. Null values are interpreted as wildmarks. Warning: $returnExplicitOnly = false
* will increase the running time significantly - USE SPARINGLY!
* @access public
* @param string aId The string id of an agent.
* @param string fId The string id of a function.
* @param string qId The string id of a qualifier. This parameter can not be null
* and used as a wildmark.
* @param object fType The type of a function.
* @param boolean returnExplicitOnly If True, only explicit Authorizations
* will be returned.
* @param boolean searchUp If true, the ancester nodes of the qualifier will
* be checked as well
* @param boolean isActiveNow If True, only active Authorizations will be returned.
* @return ref object An AuthorizationIterator.
**/
function getAZs($aId, $fId, $qId, $fType, $returnExplicitOnly, $searchUp, $isActiveNow, $groupIds = array())
{
// printpre (func_get_args());
// ** parameter validation
$rule = StringValidatorRule::getRule();
ArgumentValidator::validate($groupIds, ArrayValidatorRuleWithRule::getRule(OptionalRule::getRule($rule)), true);
ArgumentValidator::validate($aId, OptionalRule::getRule($rule), true);
ArgumentValidator::validate($fId, OptionalRule::getRule($rule), true);
ArgumentValidator::validate($qId, OptionalRule::getRule($rule), true);
ArgumentValidator::validate($fType, OptionalRule::getRule(ExtendsValidatorRule::getRule("Type")), true);
ArgumentValidator::validate($returnExplicitOnly, BooleanValidatorRule::getRule(), true);
ArgumentValidator::validate($isActiveNow, BooleanValidatorRule::getRule(), true);
// ** end of parameter validation
$idManager = Services::getService("Id");
// the parameter that influences the result most is $returnExplicitOnly
// 1) If $returnExplicitOnly is TRUE, then we only need to check for Authorizations
// that have been explicitly created, i.e. no need to look for inherited
// authorizations
// 2) If $returnExplicitOnly is FALSE, then we need to include inherited Authorizations
// as well.
// this array will store the ids of all qualifiers to be checked for authorizations
$qualifiers = array();
// check all ancestors of given qualifier
$hierarchyManager = Services::getService("Hierarchy");
if (isset($qId)) {
$qualifierId = $idManager->getId($qId);
$node = $hierarchyManager->getNode($qualifierId);
$hierarchy = $hierarchyManager->getHierarchyForNode($node);
if ($searchUp) {
// these are the ancestor nodes
$nodes = $hierarchy->traverse($qualifierId, Hierarchy::TRAVERSE_MODE_DEPTH_FIRST, Hierarchy::TRAVERSE_DIRECTION_UP, Hierarchy::TRAVERSE_LEVELS_ALL);
// now get the id of each node and store in array
while ($nodes->hasNext()) {
$info = $nodes->next();
$id = $info->getNodeId();
$qualifiers[] = $id->getIdString();
}
} else {
$qualifiers = array($qId);
}
}
// print_r($qualifiers);
// setup the query
$dbHandler = Services::getService("DatabaseManager");
$query = new SelectQuery();
$query->addColumn("authorization_id", "id");
$query->addColumn("fk_agent", "aid");
$query->addColumn("fk_function", "fid");
$query->addColumn("fk_qualifier", "qid");
$query->addColumn("authorization_effective_date", "eff_date");
$query->addColumn("authorization_expiration_date", "exp_date");
$query->addTable("az_authorization");
// now include criteria
// the qualifiers criteria
if (isset($qualifiers) && count($qualifiers)) {
$query->addWhereIn('az_authorization.fk_qualifier', $qualifiers);
}
// Agents/Groups
if (isset($aId)) {
$agentIds = array($aId);
} else {
$agentIds = array();
}
$allAgentIds = array_merge($agentIds, $groupIds);
// the agent criteria
if (count($allAgentIds)) {
$query->addWhereIn('az_authorization.fk_agent', $allAgentIds);
}
// the function criteria
if (isset($fId)) {
$joinc = "az_authorization.fk_function = az_function.function_id";
$query->addTable("az_function", INNER_JOIN, $joinc);
$query->addWhereEqual("az_authorization.fk_function", $fId);
}
// the function type criteria
if (isset($fType)) {
// do not join with az_function if we did already
if (!isset($fId)) {
$joinc = "az_authorization.fk_function = az_function.function_id";
$query->addTable("az_function", INNER_JOIN, $joinc);
}
// now join with type
$joinc = "az_function.fk_type = type.type_id";
//.........这里部分代码省略.........
示例10: buildContent
/**
* Build the content for this action
*
* @return void
* @access public
* @since 4/26/05
*/
function buildContent()
{
require_once HARMONI . "/utilities/Timer.class.php";
$execTimer = new Timer();
$execTimer->start();
$harmoni = Harmoni::instance();
$idManager = Services::getService("Id");
$slideshowAsset = $this->getAsset();
/*********************************************************
* First print the header, then the xml content, then exit before
* the GUI system has a chance to try to theme the output.
*********************************************************/
header("Content-Type: text/xml; charset=\"utf-8\"");
print <<<END
<?xml version="1.0" encoding="utf-8" ?>
<!DOCTYPE slideshow PUBLIC "- //Middlebury College//Slide-Show//EN" "http://concerto.sourceforge.net/dtds/viewer/2.0/slideshow.dtd">
<slideshow>
END;
print "\t<title>" . $slideshowAsset->getDisplayName() . "</title>\n";
print "\t<default_size>medium</default_size>\n";
$setManager = Services::getService("Sets");
$slideshowSet = $setManager->getPersistentSet($slideshowAsset->getId());
$slideIterator = $slideshowAsset->getAssets();
$orderedSlides = array();
$unorderedSlides = array();
while ($slideIterator->hasNext()) {
$slideAsset = $slideIterator->next();
$slideAssetId = $slideAsset->getId();
if ($slideshowSet->isInSet($slideAssetId)) {
$orderedSlides[$slideshowSet->getPosition($slideAssetId)] = $slideAsset;
} else {
$unorderedSlides[] = $slideAsset;
}
}
ksort($orderedSlides);
$slides = array_merge($orderedSlides, $unorderedSlides);
unset($orderedSlides, $unorderedSlides);
foreach (array_keys($slides) as $key) {
$this->printSlide($slides[$key]);
}
$execTimer->end();
print "\n\n<ExecutionTime>";
printf("%1.6f", $execTimer->printTime());
print "</ExecutionTime>\n";
$dbhandler = Services::getService("DBHandler");
print "<NumQueries>" . $dbhandler->getTotalNumberOfQueries() . "</NumQueries>\n";
print "</slideshow>\n";
exit;
}