function neighbourhood(AssessmentTestSession $session, array &$average = null) { $start = microtime(); $neighbourhood = $session->getPossibleJumps(); if (is_null($average) === false) { spentTime($start, microtime(), $average); } }
function testAssessmentTests(array $files, $validate = false) { $loaded = 0; $totalSpent = 0; foreach ($files as $f) { $start = microtime(); $testDoc = new XmlDocument(); $testDoc->load($f, $validate); $end = microtime(); $spent = spentTime($start, $end); $totalSpent += $spent; output("Test '" . pathinfo($f, PATHINFO_BASENAME) . "' loaded in " . sprintf("%.8f", $spent) . " seconds."); $partCount = count($testDoc->getDocumentComponent()->getComponentsByClassName('testPart')); $sectionCount = count($testDoc->getDocumentComponent()->getComponentsByClassName('assessmentSection')); $itemCount = count($testDoc->getDocumentComponent()->getComponentsByClassName('assessmentItemRef')); outputDescription("{$partCount} testPart(s), {$sectionCount} assessmentSection(s), {$itemCount} assessmentItemRef(s)"); outputDescription("Memory usage is " . memory_get_usage() / pow(1024, 2) . " MB"); output(''); $loaded++; } outputAverage($totalSpent / $loaded); }
$phpTimings = array('match_correct' => array(), 'map_response' => array(), 'map_response_point' => array()); $iterations = 100; foreach ($templates as $t) { for ($i = 0; $i < $iterations; $i++) { // --- XML $start = microtime(); $xmlDoc = new XmlDocument('2.1'); $xmlDoc->load(dirname(__FILE__) . $basePath . $t . '.xml'); $end = microtime(); $xmlTimings[$t][] = spentTime($start, $end); // --- PHP $start = microtime(); $phpDoc = new PhpDocument(); $phpDoc->load(dirname(__FILE__) . $basePath . $t . '.php'); $end = microtime(); $phpTimings[$t][] = spentTime($start, $end); } } foreach ($templates as $t) { // compute arithmetic mean. $meanXml = 0; foreach ($xmlTimings[$t] as $v) { $meanXml += $v; } $meanXml = $meanXml / $iterations; // compute arithmetic mean. $meanPhp = 0; foreach ($phpTimings[$t] as $v) { $meanPhp += $v; } $meanPhp = $meanPhp / $iterations;