/** Executes the needed operator(s). Checks operator names, and calls the appropriate functions. */ function modify($tpl, $operatorName, $operatorParameters, $rootNamespace, $currentNamespace, &$operatorValue, $namedParameters) { switch ($operatorName) { case 'xhprof_start': eZXHProfLogger::start($namedParameters['flags'], $namedParameters['options']); $operatorValue = null; break; case 'xhprof_stop': eZXHProfLogger::stop($namedParameters['dosave']); $operatorValue = null; break; case 'record_value': eZPerfLogger::recordValue($namedParameters['name'], $operatorValue); $operatorValue = null; break; case 'make_global': /// @todo investigate: shal we use copy if $operatorValue is an object? $GLOBALS[$namedParameters['name']] = $namedParameters['value']; $operatorValue = null; } }
/** * This method is meant to be registered for execution at end of page execution. It does * the actual logging of the performance variables values according to the * configuration in ezperformancelogger.ini, as well as the xhprof profile * dumping. * When xhprof is enabled, it adds an html comment to page output which can be used to link to pages displaying * profiling information * (this method runs before debug output is added to it, so we can not add it there) */ public static function filter($output, $returnCode = null) { if (self::$activated) { self::$has_run = true; // perf logging: measure variables and log them according to configuration $values = self::getValues(true, $output, $returnCode); self::logIfNeeded($values, $output); // profiling if (eZXHProfLogger::isRunning()) { eZXHProfLogger::stop(); } if (eZPerfLoggerINI::variable('XHProfSettings', 'AppendXHProfTag') == 'enabled' && ($runs = eZXHProfLogger::runs())) { $xhtag = "<!-- XHProf runs: " . implode(',', $runs) . " -->"; $output = preg_replace("#</body>#", $xhtag . '</body>', $output, -1, $count); if ($count == 0) { $output .= $xhtag; } } } return $output; }