本文整理汇总了PHP中Magento_Profiler::fetch方法的典型用法代码示例。如果您正苦于以下问题:PHP Magento_Profiler::fetch方法的具体用法?PHP Magento_Profiler::fetch怎么用?PHP Magento_Profiler::fetch使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Magento_Profiler
的用法示例。
在下文中一共展示了Magento_Profiler::fetch方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: _aggregateTimerValues
/**
* Calculate metric value from set of timer names
*
* @param array $timerNames
* @param string $fetchKey
* @return int
*/
protected function _aggregateTimerValues(array $timerNames, $fetchKey = Magento_Profiler::FETCH_AVG)
{
/* Prepare pattern that matches timers with deepest nesting level only */
$nestingSep = preg_quote(Magento_Profiler::NESTING_SEPARATOR, '/');
array_map('preg_quote', $timerNames, array('/'));
$pattern = '/(?<=' . $nestingSep . '|^)(?:' . implode('|', $timerNames) . ')$/';
/* Sum profiler values for matched timers */
$result = 0;
foreach ($this->_getTimers() as $timerId) {
if (preg_match($pattern, $timerId)) {
$result += Magento_Profiler::fetch($timerId, $fetchKey);
}
}
/* Convert seconds -> milliseconds */
$result = round($result * 1000);
return $result;
}
示例2: _getTimers
/**
* Retrieve the list of timer Ids
*
* @return array
*/
protected function _getTimers()
{
$pattern = $this->_filter;
$timerIds = $this->_getSortedTimers();
$result = array();
foreach ($timerIds as $timerId) {
/* Filter by timer id pattern */
if ($pattern && !preg_match($pattern, $timerId)) {
continue;
}
/* Filter by column value thresholds */
$skip = false;
foreach ($this->_thresholds as $fetchKey => $minAllowedValue) {
$skip = Magento_Profiler::fetch($timerId, $fetchKey) < $minAllowedValue;
/* First value not less than the allowed one forces to include timer to the result */
if (!$skip) {
break;
}
}
if (!$skip) {
$result[] = $timerId;
}
}
return $result;
}
示例3: testFetchException
/**
* @dataProvider fetchExceptionDataProvider
* @expectedException Varien_Exception
*/
public function testFetchException($timerId, $fetchKey)
{
Magento_Profiler::fetch($timerId, $fetchKey);
}