本文整理汇总了PHP中UTIL_Profiler::getTotalTime方法的典型用法代码示例。如果您正苦于以下问题:PHP UTIL_Profiler::getTotalTime方法的具体用法?PHP UTIL_Profiler::getTotalTime怎么用?PHP UTIL_Profiler::getTotalTime使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类UTIL_Profiler
的用法示例。
在下文中一共展示了UTIL_Profiler::getTotalTime方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: execute
/**
* Returns current PDOStatement
*
* @return PDOStatement
*/
private function execute($sql, array $params = null)
{
if ($this->isProfilerEnabled) {
$this->profiler->reset();
}
/* @var $stmt PDOStatement */
$stmt = $this->connection->prepare($sql);
if ($params !== null) {
foreach ($params as $key => $value) {
$paramType = PDO::PARAM_STR;
if (is_int($value)) {
$paramType = PDO::PARAM_INT;
} elseif (is_bool($value)) {
$paramType = PDO::PARAM_BOOL;
}
$stmt->bindValue(is_int($key) ? $key + 1 : $key, $value, $paramType);
}
}
OW::getEventManager()->trigger(new OW_Event("core.sql.exec_query", array("sql" => $sql, "params" => $params)));
$stmt->execute();
//TODO setup profiler
$this->affectedRows = $stmt->rowCount();
if ($this->isProfilerEnabled) {
$this->queryExecTime = $this->profiler->getTotalTime();
$this->totalQueryExecTime += $this->queryExecTime;
$this->queryCount++;
$this->queryLog[] = array('query' => $sql, 'execTime' => $this->queryExecTime, 'params' => $params);
}
return $stmt;
}
示例2: call
/**
* Calls last event listener and returns it's result value.
*
* @param string $eventName
* @param array $eventParams
* @return mixed
*/
public function call($eventName, $eventParams = array())
{
$event = new OW_Event($eventName, $eventParams);
if (!empty($this->listeners[$eventName])) {
ksort($this->listeners[$event->getName()]);
// log triggered events for developer mode
if ($this->devMode) {
$startTime = UTIL_Profiler::getInstance()->getTotalTime();
$this->profiler->reset();
$handlers = reset($this->listeners[$eventName]);
$result = call_user_func(end($handlers), $event);
if (!in_array($event->getName(), $this->eventsToSkip) && count($this->eventsLog) < $this->maxItemsInLog) {
$this->eventsLog[] = array('type' => 'call', 'start' => $startTime, 'exec' => $this->profiler->getTotalTime(), 'event' => $event, 'listeners' => $this->listeners[$event->getName()]);
}
} else {
$handlers = reset($this->listeners[$eventName]);
$result = call_user_func(end($handlers), $event);
}
return $result;
} else {
// log events with no listeners
$startTime = UTIL_Profiler::getInstance()->getTotalTime();
if ($this->devMode && !in_array($event->getName(), $this->eventsToSkip) && count($this->eventsLog) < $this->maxItemsInLog) {
$this->eventsLog[] = array('type' => 'call', 'start' => $startTime, 'event' => $event, 'listeners' => array(), 'exec' => 0);
}
}
}