public function displayFooter($display = true)
 {
     // This method will be removed in 1.6
     parent::displayFooter();
     require_once dirname(__FILE__) . '../../../../modules/designerpreview/defines.inc.php';
     $this->smartyOutputContent(getThemeDir() . 'footer.tpl');
 }
Ejemplo n.º 2
0
    public function displayFooter()
    {
        global $start_time;
        if (self::$_footer) {
            parent::displayFooter();
        }
        if (!$this->ini_get_display_errors()) {
            return;
        }
        $this->_memory[6] = memory_get_usage();
        $this->_time[6] = microtime(true);
        $hr = '<hr style="color:#F5F5F5;margin:2px" />';
        $totalSize = 0;
        foreach (get_included_files() as $file) {
            $totalSize += filesize($file);
        }
        $totalQueryTime = 0;
        foreach (Db::getInstance()->queriesTime as $time) {
            $totalQueryTime += $time;
        }
        $hooktime = Module::getHookTime();
        arsort($hooktime);
        $totalHookTime = 0;
        foreach ($hooktime as $time) {
            $totalHookTime += $time;
        }
        $globalSize = array();
        $totalGlobalSize = 0;
        foreach ($GLOBALS as $key => $value) {
            if ($key != 'GLOBALS') {
                $totalGlobalSize += $size = $this->sizeofvar($value);
                if ($size > 1024) {
                    $globalSize[$key] = round($size / 1024, 1);
                }
            }
        }
        arsort($globalSize);
        echo '<br /><br />
		<div class="rte" style="text-align:left;padding:8px;float:left">
			<b>Load time</b>: ' . $this->displayLoadTimeColor($this->_time[6] - $start_time, true) . '';
        if (self::$_footer) {
            echo '
			<ul>
				<li>Config: ' . $this->displayLoadTimeColor($this->_time[-3] - $start_time) . '</li>
				<li>Init: ' . $this->displayLoadTimeColor($this->_time[-2] - $this->_time[-3]) . '</li>
				<li>Constructor: ' . $this->displayLoadTimeColor($this->_time[-1] - $this->_time[-2]) . '</li>
				<li>preProcess: ' . $this->displayLoadTimeColor($this->_time[1] - $this->_time[0]) . '</li>
				<li>setMedia: ' . $this->displayLoadTimeColor($this->_time[2] - $this->_time[1]) . '</li>
				<li>displayHeader: ' . $this->displayLoadTimeColor($this->_time[3] - $this->_time[2]) . '</li>
				<li>process: ' . $this->displayLoadTimeColor($this->_time[4] - $this->_time[3]) . '</li>
				<li>displayContent: ' . $this->displayLoadTimeColor($this->_time[5] - $this->_time[4]) . '</li>
				<li>displayFooter: ' . $this->displayLoadTimeColor($this->_time[6] - $this->_time[5]) . '</li>
			</ul>';
        }
        echo '</div>
		<div class="rte" style="text-align:left;padding:8px;float:left;margin-left:20px">
			<b>Hook processing</b>: ' . $this->displayLoadTimeColor($totalHookTime) . '
			<ul>';
        foreach ($hooktime as $hook => $time) {
            echo '<li>' . $hook . ': ' . $this->displayLoadTimeColor($time) . '</li>';
        }
        echo '</ul>
		</div>
		<div class="rte" style="text-align:left;padding:8px;float:left;margin-left:20px">
			<b>Memory peak usage</b>: ' . $this->displayMemoryColor(memory_get_peak_usage()) . '';
        if (self::$_footer) {
            echo '
			<ul>
				<li>Config: ' . $this->displayMemoryColor($this->_memory[-3]) . '</li>
				<li>Init: ' . $this->displayMemoryColor($this->_memory[-2] - $this->_memory[-3]) . '</li>
				<li>Constructor: ' . $this->displayMemoryColor($this->_memory[-1] - $this->_memory[-2]) . '</li>
				<li>preProcess: ' . $this->displayMemoryColor($this->_memory[1] - $this->_memory[0]) . '</li>
				<li>setMedia: ' . $this->displayMemoryColor($this->_memory[2] - $this->_memory[1]) . '</li>
				<li>displayHeader: ' . $this->displayMemoryColor($this->_memory[3] - $this->_memory[2]) . '</li>
				<li>process: ' . $this->displayMemoryColor($this->_memory[4] - $this->_memory[3]) . '</li>
				<li>displayContent: ' . $this->displayMemoryColor($this->_memory[5] - $this->_memory[4]) . '</li><li>displayFooter: ' . $this->displayMemoryColor($this->_memory[6] - $this->_memory[5]) . '</li>
			</ul>';
        }
        echo '</div>';
        $countByTypes = '';
        foreach (Db::getInstance()->countTypes as $type => $count) {
            if ($count) {
                $countByTypes .= '<li>' . $count . ' x ' . $type . '</li>';
            }
        }
        $countByTypes = rtrim($countByTypes, ' |');
        echo '
		<div class="rte" style="text-align:left;padding:8px;float:left;margin-left:20px">
			<b>SQL Queries</b>: ' . $this->displaySQLQueries(Db::getInstance()->count) . '
			<ul>' . $countByTypes . '</ul>
			<br /><b>Time spent querying</b>: ' . $this->displayLoadTimeColor($totalQueryTime) . '
		</div>
		<div class="rte" style="text-align:left;padding:8px;float:left;margin-left:20px">
			<b>Included files</b>: ' . sizeof(get_included_files()) . '<br />
			<b>Size of included files</b>: ' . $this->displayMemoryColor($totalSize) . '
		</div>
		<div class="rte" style="text-align:left;padding:8px;float:left;margin-left:20px">
			<b>Globals (&gt; 1 Ko only): ' . round($totalGlobalSize / 1024) . ' Ko</b>
			<ul>';
        foreach ($globalSize as $global => $size) {
            echo '<li>' . $global . ' &asymp; ' . $size . ' Ko</li>';
        }
        echo '</ul>
		</div>';
        echo '
		<div class="rte" style="text-align:left;padding:8px;clear:both;margin-top:20px">
			<ul>
				<li><a href="#stopwatch">Go to Stopwatch</a></li>
				<li><a href="#doubles">Go to Doubles</a></li>
				<li><a href="#tables">Go to Tables</a></li>
			</ul>
		</div>
		<div class="rte" style="text-align:left;padding:8px">
		<h3><a name="stopwatch">Stopwatch (with SQL_NO_CACHE)</a></h3>';
        $queries = Db::getInstance()->queriesTime;
        arsort($queries);
        foreach ($queries as $q => $time) {
            echo $hr . '<b ' . $this->getTimeColor($time * 1000) . '>' . round($time * 1000, 3) . ' ms</b> ' . $q;
        }
        echo '</div>
		<div class="rte" style="text-align:left;padding:8px">
		<h3><a name="doubles">Doubles (IDs replaced by "XX")</a></h3>';
        $queries = Db::getInstance()->queries;
        arsort($queries);
        foreach ($queries as $q => $nb) {
            echo $hr . '<b ' . $this->getQueryColor($nb) . '>' . $nb . '</b> ' . $q;
        }
        echo '</div>
		<div class="rte" style="text-align:left;padding:8px">
		<h3><a name="tables">Tables stress</a></h3>';
        $tables = Db::getInstance()->tables;
        arsort($tables);
        foreach ($tables as $table => $nb) {
            echo $hr . '<b ' . $this->getTableColor($nb) . '>' . $nb . '</b> ' . $table;
        }
        echo '</div>';
    }