Created
March 1, 2012 18:36
-
-
Save opengeek/1952005 to your computer and use it in GitHub Desktop.
Simple benchmark for iterative MODX Chunk parsing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
include 'config.core.php'; | |
include MODX_CORE_PATH . 'model/modx/modx.class.php'; | |
$modx = new modX(); | |
$modx->initialize('web'); | |
$modx->setLogTarget(XPDO_CLI_MODE ? 'ECHO' : 'HTML'); | |
$modx->setLogLevel(xPDO::LOG_LEVEL_INFO); | |
$tstart = $modx->getMicroTime(); | |
$chunk = $modx->getObject('modChunk', array('name' => 'testSpeed')); | |
for ($i = 0; $i < 1000; $i++) { | |
$chunk->process(array('i' => $i)); | |
} | |
$tend = $modx->getMicroTime(); | |
$modx->log(modX::LOG_LEVEL_INFO, sprintf("Processed 1000 chunks using getObject — %2.4f s\n", $tend - $tstart)); | |
$tstart = $modx->getMicroTime(); | |
$chunk = $modx->getParser()->getElement('modChunk', 'testSpeed'); | |
for ($i = 0; $i < 1000; $i++) { | |
$chunk->process(array('i' => $i)); | |
} | |
$tend = $modx->getMicroTime(); | |
$modx->log(modX::LOG_LEVEL_INFO, sprintf("Processed 1000 chunks using modParser::getElement — %2.4f s\n", $tend - $tstart)); | |
$tstart = $modx->getMicroTime(); | |
for ($i = 0; $i < 1000; $i++) { | |
$modx->getChunk('testSpeed', array('i' => $i)); | |
} | |
$tend = $modx->getMicroTime(); | |
$modx->log(modX::LOG_LEVEL_INFO, sprintf("Processed 1000 chunks using getChunk — %2.4f s\n", $tend - $tstart)); | |
$tstart = $modx->getMicroTime(); | |
$content = include 'test-content.php'; | |
for ($i = 0; $i < 1000; $i++) { | |
$iContent = $content; | |
$modx->setPlaceholder('i', $i); | |
$modx->getParser()->processElementTags('', $iContent); | |
} | |
$tend = $modx->getMicroTime(); | |
$modx->log(modX::LOG_LEVEL_INFO, sprintf("Processed 1000 iterations on included content using modParser::processElementTags — %2.4f s\n", $tend - $tstart)); | |
exit(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment