Skip to content

Instantly share code, notes, and snippets.

@opengeek
Created October 1, 2010 19:09
Show Gist options
  • Save opengeek/606684 to your computer and use it in GitHub Desktop.
Save opengeek/606684 to your computer and use it in GitHub Desktop.
<?php
$output = '';
$tElementClass = !empty($tElementClass) ? $tElementClass : 'modSnippet';
$tStart = $modx->getMicroTime();
if (!empty($tElement)) {
switch ($tElementClass) {
case 'modChunk':
$output = $modx->getChunk($tElement, $scriptProperties);
break;
case 'modSnippet':
$output = $modx->runSnippet($tElement, $scriptProperties);
break;
default:
$tElementObj = $modx->getObject($tElementClass, array('name' => $tElement));
if ($tElementObj && $tElementObj instanceof modElement) {
$tElementObj->setCacheable(false);
$output = $tElementObj->process($scriptProperties);
} else {
$modx->log(modX::LOG_LEVEL_ERROR, "{$tElementClass}: {$tElement} is not a valid MODx Element");
}
break;
}
}
$tEnd = $modx->getMicroTime();
$modx->log(modX::LOG_LEVEL_ERROR, "{$tElementClass}: {$tElement} executed in " . sprintf("%2.4f s", $tEnd - $tStart));
return $output;
?>
@blueeyeddevil
Copy link

is this snippet still in development? If so, wouldn't be possible to add an option for automatically wrapping all snippets or chunks and displaying execution time for each element at the end of its code on the page?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment