Added backtrace output
authorMarcel Werk <burntime@woltlab.com>
Tue, 16 Oct 2012 23:18:26 +0000 (01:18 +0200)
committerMarcel Werk <burntime@woltlab.com>
Tue, 16 Oct 2012 23:18:26 +0000 (01:18 +0200)
com.woltlab.wcf/template/benchmark.tpl
wcfsetup/install/files/lib/system/benchmark/Benchmark.class.php

index ce53d47ebf2eecc5aa516855df63f5b7dfbae4a5..f0327ec0472697beae780bbe960dd0a4f5afdad6 100644 (file)
@@ -1,9 +1,25 @@
 <p class="marginTop" id="benchmark"><small>Execution time: {@$__wcf->getBenchmark()->getExecutionTime()}s ({#($__wcf->getBenchmark()->getExecutionTime()-$__wcf->getBenchmark()->getQueryExecutionTime())/$__wcf->getBenchmark()->getExecutionTime()*100}% PHP, {#$__wcf->getBenchmark()->getQueryExecutionTime()/$__wcf->getBenchmark()->getExecutionTime()*100}% SQL) | SQL queries: {#$__wcf->getBenchmark()->getQueryCount()} | Memory-Usage: {$__wcf->getBenchmark()->getMemoryUsage()}</small></p>
 
 {if ENABLE_DEBUG_MODE} 
+       <script type="text/javascript">
+               //<![CDATA[
+               $(function() {
+                       $('#benchmarkDetails > li > span').click(function() {
+                               $(this).parent().children('pre').toggle();
+                       });
+               });
+               //]]>
+       </script>
        <ul id="benchmarkDetails" style="display: none;">
-               {foreach from=$__wcf->getBenchmark()->getItems() item=item}
-                       <li style="margin-bottom: 8px;"{if $item.use >= 0.01} class="hot"{/if}>{if $item.type == 1}(SQL Query) {/if}{$item.text}<br /><small style="font-size: .85em">Execution time: {@$item.use}s</small></li>
+               {foreach from=$__wcf->getBenchmark()->getItems() key=benchmarkIndex item=item}
+                       <li id="benchmarkItem{@$benchmarkIndex}" style="margin-bottom: 8px;"{if $item.use >= 0.01} class="hot"{/if}>
+                               <span>{if $item.type == 1}(SQL Query) {/if}{$item.text}</span><br />
+                               <small style="font-size: .85em">Execution time: {@$item.use}s</small>
+                               
+                               <pre style="display: none">{foreach from=$item.trace key=traceNo item=traceItem}#{#$traceNo} {if !$traceItem.class|empty}{$traceItem.class}{$traceItem.type}{else}{$traceItem.file}: {/if}{$traceItem.function}() {if !$traceItem.line|empty}(line {#$traceItem.line}){/if} 
+{/foreach}</pre>
+                               
+                       </li>
                {/foreach}
        </ul>
        
index 76b2349a560925d6d8ea24f5f3bf457fd3a54e3e..aa20ce5bfe19a2a352e7b5a0ed848859109285c5 100644 (file)
@@ -61,6 +61,7 @@ class Benchmark extends SingletonFactory {
                $this->items[$newIndex]['type'] = $type;
                $this->items[$newIndex]['before'] = self::getMicrotime();
                $this->items[$newIndex]['start'] = self::compareMicrotimes($this->startTime, $this->items[$newIndex]['before']);
+               $this->items[$newIndex]['trace'] = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS);
                return $newIndex;
        }