Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Merge pull request #1 from corretge/master

replace broken images with an unicode symbol
  • Loading branch information...
commit 8c892dbe5435fc0baede067a6d2e5a65523c9c1b 2 parents 33d30c7 + 67ef816
@beberlei authored
Showing with 583 additions and 149 deletions.
  1. +45 −0 trace.config.php
  2. +49 −28 trace.css
  3. +476 −121 trace.php
  4. +13 −0 xdebug.ini
View
45 trace.config.php
@@ -2,6 +2,8 @@
$config['directory'] = ini_get('xdebug.trace_output_dir');
+ini_set('xdebug.auto_trace', 'Off');
+
/**
* Do not modify below this line :)
* ...unless you really, really, reaaaally want to
@@ -9,3 +11,46 @@
// get our own trace files
$ownTraces = file_get_contents('trace-own.cache');
$ownTraces = explode(PHP_EOL, $ownTraces);
+
+define('XDEBUG_TRACE_GUI_MEMORY_TRIGGER', '0.3');
+define('XDEBUG_TRACE_GUI_TIME_TRIGGER', '0.03');
+
+define('XDEBUG_TRACE_GUI_CUSTOM_NAMESPACE', 'Corretge\\');
+
+function aryComp($a, $b)
+{
+ if ($a['cnt'] == $b['cnt']) {
+ return 0;
+ }
+ /**
+ * fem-ho desc
+ */
+ return ($a['cnt'] > $b['cnt']) ? -1 : 1;
+}
+
+function usortByArrayKey(&$array, $key, $asc=SORT_ASC) {
+ $sort_flags = array(SORT_ASC, SORT_DESC);
+ if(!in_array($asc, $sort_flags)) throw new InvalidArgumentException('sort flag only accepts SORT_ASC or SORT_DESC');
+ $cmp = function(array $a, array $b) use ($key, $asc, $sort_flags) {
+ if(!is_array($key)) { //just one key and sort direction
+ if(!isset($a[$key]) || !isset($b[$key])) {
+ throw new Exception('attempting to sort on non-existent keys');
+ }
+ if($a[$key] == $b[$key]) return 0;
+ return ($asc==SORT_ASC xor $a[$key] < $b[$key]) ? 1 : -1;
+ } else { //using multiple keys for sort and sub-sort
+ foreach($key as $sub_key => $sub_asc) {
+ //array can come as 'sort_key'=>SORT_ASC|SORT_DESC or just 'sort_key', so need to detect which
+ if(!in_array($sub_asc, $sort_flags)) { $sub_key = $sub_asc; $sub_asc = $asc; }
+ //just like above, except 'continue' in place of return 0
+ if(!isset($a[$sub_key]) || !isset($b[$sub_key])) {
+ throw new Exception('attempting to sort on non-existent keys');
+ }
+ if($a[$sub_key] == $b[$sub_key]) continue;
+ return ($sub_asc==SORT_ASC xor $a[$sub_key] < $b[$sub_key]) ? 1 : -1;
+ }
+ return 0;
+ }
+ };
+ usort($array, $cmp);
+}
View
77 trace.css
@@ -1,77 +1,98 @@
*,html * {
- font: 12px verdana, sans-serif;
- color: black;
+ font: 12px verdana, sans-serif;
+ color: black;
}
strong {
- font-weight: bold;
+ font-weight: bold;
}
small {
- font-size: 11px;
+ font-size: 11px;
}
h1 {
- font-size: 24px;
- font-weight: bold;
+ font-size: 24px;
+ font-weight: bold;
}
h2 {
- font-size: 18px;
+ font-size: 18px;
}
label {
- display: block;
- margin-bottom: 5px;
+ display: block;
+ margin-bottom: 5px;
}
img {
- vertical-align: middle;
- border: 0;
+ vertical-align: middle;
+ border: 0;
}
table {
- width: 100%;
+ width: 100%;
}
td,th {
- padding: 3px;
- vertical-align: top;
+ padding: 3px;
+ vertical-align: top;
}
th {
- background: #343434;
- color: white;
- text-align: left;
+ background: #343434;
+ color: white;
+ text-align: left;
}
td.digit {
- text-align: right;
+ text-align: right;
}
a {
- color: navy;
- text-decoration: none;
+ color: navy;
+ text-decoration: none;
}
a:hover {
- text-decoration: underline;
+ text-decoration: underline;
}
a:visited {
- color: purple;
+ color: purple;
}
span.warning {
- font-weight: bold;
- color: maroon;
- font-size: 11px;
+ font-weight: bold;
+ color: maroon;
+ font-size: 11px;
}
tr.near td {
- background: #fffac1;
+ background: #fffac1;
}
tr.line td {
- background: #f7f09f;
-}
+ background: #f7f09f;
+}
+
+span.user {
+ color: chartreuse;
+}
+
+span.native {
+ color: lightseagreen;
+}
+
+
+span.Zend {
+ color: yellowgreen;
+}
+
+span.Corretge {
+ color: coral;
+}
+
+
+tr:nth-child(even) {background: ivory;}
+tr:nth-child(odd) {background: aliceblue;}
View
597 trace.php
@@ -1,6 +1,7 @@
<?php
require 'trace.config.php';
-error_reporting(0);
+
+//error_reporting(0);
?>
<html>
<head>
@@ -12,165 +13,519 @@
</head>
<body>
<h1>Xdebug Trace File Parser</h1>
- <h2>Settings</h2>
+ <h2>Settings <?= $config['directory'] ?></h2>
<form method="get" action="trace.php">
<label>File
<select name="file">
<option value="" selected="selected"> -- Select -- </option>
<?php
$files = new DirectoryIterator($config['directory']);
- foreach ($files as $file) {
+ foreach ($files as $file)
+ {
- if (substr_count($file->getFilename(), '.xt') == 0 || in_array($config['directory'] . '/' . $file->getFilename(), $ownTraces)) {
+ if (substr_count($file->getFilename(), '.xt') == 0 || in_array($config['directory'] . '/' . $file->getFilename(),
+ $ownTraces))
+ {
continue;
}
$date = explode('.', $file->getFilename());
- $date = date('Y-m-d H:i:s', $date [0]);
+ $date = date('Y-m-d H:i:s', $file->getCTime());
+
- echo '<option value="' . $file->getFilename() . '"> ' . $date . ' - ' . $file->getFilename() . ' </option>';
+ echo '<option value="' . $file->getFilename() . '"> ' . $date . ' - ' . $file->getFilename() . '- ' . number_format($file->getSize() / 1024,
+ 0,
+ ',',
+ '.') . ' KB</option>';
}
?>
</select>
</label>
- <label>If the memory jumps <input type="text" name="memory" value="0.3" style="text-align:right" size="5"/> MB, provide an alert</label>
- <label>If the execution time jumps <input type="text" name="time" value="0.3" style="text-align:right" size="5"/> seconds, provide an alert</label>
+ <label>If the memory jumps <input type="text" name="memory" value="<?= XDEBUG_TRACE_GUI_MEMORY_TRIGGER ?>" style="text-align:right" size="5"/> MB, provide an alert</label>
+ <label>If the execution time jumps <input type="text" name="time" value="<?= XDEBUG_TRACE_GUI_TIME_TRIGGER ?>" style="text-align:right" size="5"/> seconds, provide an alert</label>
<input type="submit" value="parse" />
</form>
+ <br /><a href="#sumary">Resum</a>
+ <?php
+ if (!isset($_GET['file']))
+ {
+ exit;
+ }
+ ?>
<h2>Output</h2>
-<?php
- $traceFile = $config['directory'] . '/' . $_GET ['file'];
+ <?php
+ /**
+ * retrieve the xdebug.trace_format ini set.
+ */
+ $xdebug_trace_format = ini_get('xdebug.trace_format');
+ $XDEBUG_TRACE_GUI_CUSTOM_NAMESPACE_LEN = strlen(XDEBUG_TRACE_GUI_CUSTOM_NAMESPACE);
- $memJump = 1;
- if (isset($_GET['memory'])) {
- $memJump = (float) $_GET['memory'];
- }
+ $traceFile = $config['directory'] . '/' . $_GET ['file'];
- $timeJump = 1;
- if (isset($_GET['time'])) {
- $timeJump = (float) $_GET['time'];
- }
- if (!isset($_GET ['file']) || empty($_GET ['file'])) {
- echo '<p>No file selected</p>';
- } else if (!file_exists($traceFile)) {
- echo '<p>Invalid file</p>';
- } else {
-
- $trace = file_get_contents($traceFile);
- $lines = explode("\n", $trace);
- $previousLevel = 0;
- $levelIds = array();
- $ids = 0;
- $defFn = get_defined_functions();
-
- foreach ($lines as $line) {
-
- if (substr_count($line, "\t") >= 5) {
- $data = explode("\t", $line);
- list($level, $id, $point, $time, $memory, $function, $type, $file, $filename, $line) = $data;
- $memory = round($memory / (1024 * 1024), 4);
- } else {
- $strippedLine = preg_replace('(([\s]{2,}))', ' ', trim($line));
- list ($time, $memory) = explode(" ", $strippedLine);
- $memory = round($memory / (1024 * 1024), 4);
-
- $level = round(((strpos($line, '->') - strpos($line, $memory) + strlen($memory))) / 2);
- if ($level <= $previousLevel && isset($levelIds[$level])) {
- $fullTrace[$levelIds[$level]]['timeOnExit'] = $time;
- $fullTrace[$levelIds[$level]]['memoryOnExit'] = $memory;
- }
- $id = ++$ids;
- $levelIds[$level] = $id;
- $previousLevel = $level;
-
- $parts = array_map('trim', explode("->", $line, 2));
- $parts = explode(" ", $parts[1]);
- $function = $parts[0];
- list($line, $file) = array_map('strrev', explode(":", strrev($parts[1]), 2));
- $filename = $file;
- $point = 0;
- $type = in_array(substr($function, 0, strpos($function, "(")), $defFn['internal']) ? 0 : 1;
- }
+ $memJump = 1;
+ if (isset($_GET['memory']))
+ {
+ $memJump = (float) $_GET['memory'];
+ }
- if (empty($function)) {
- $fullTrace[$id]['timeOnExit'] = $time;
- $fullTrace[$id]['memoryOnExit'] = $memory;
- continue;
- }
+ $timeJump = 1;
+ if (isset($_GET['time']))
+ {
+ $timeJump = (float) $_GET['time'];
+ }
- if ($point == 0) {
- // starting function
- $fullTrace[$id] = array('level' => $level, 'id' => $id, 'timeOnEntry' => $time, 'memoryOnEntry' => $memory, 'function' => $function, 'type' => $type, 'file' => $file, 'filename' => $filename, 'line' => $line);
+ if (!isset($_GET ['file']) || empty($_GET ['file']))
+ {
+ echo '<p>No file selected</p>';
+ }
+ else if (!file_exists($traceFile))
+ {
+ echo '<p>Invalid file</p>';
+ }
+ else
+ {
- if (($memory - $lastMemory) > $memJump) {
- $fullTrace[$id]['memoryAlert'] = $memory - $lastMemory;
- } else {
- $fullTrace[$id]['memoryAlert'] = false;
- }
- if (($time - $lastTime) > $timeJump) {
- $fullTrace[$id]['timeAlert'] = $time - $lastTime;
- } else {
- $fullTrace[$id]['timeAlert'] = false;
- }
+ /**
+ * és una manera molt poc eficient de llegir un arxiu.
+ */
+ //$trace = file_get_contents($traceFile);
+ //$lines = explode("\n", $trace);
- $lastMemory = $memory;
- $lastTime = $time;
- } else {
- $fullTrace[$id]['timeOnExit'] = $time;
- $fullTrace[$id]['memoryOnExit'] = $memory;
+
+ $previousLevel = 0;
+ $levelIds = array();
+ $ids = 0;
+
+
+ $defFn = get_defined_functions();
+ /**
+ * counter
+ */
+ $jCnt = 0;
+
+ /**
+ * Sumary
+ */
+ $aSumary = array();
+ $aSumaryS = array();
+
+ /**
+ * Process all lines
+ */
+ //foreach ($lines as $line)
+ $fh = fopen($traceFile, 'r');
+ while ($jReadedLine = fgets($fh))
+ {
+ /**
+ * Add one to the counter
+ */
+ $jCnt++;
+
+ switch ($xdebug_trace_format)
+ {
+ /**
+ * xdebug.trace_format = 1 Computerized
+ * @link http://www.xdebug.org/docs/all_settings#trace_format
+ */
+ case 1:
+ $data = explode("\t", $jReadedLine);
+ @list($level, $id, $point, $time, $memory, $function, $type, $file, $filename, $line, $numParms) = $data;
+
+ /**
+ * if there is params save it
+ */
+ if (isset($numParms) and $numParms > 0)
+ {
+ $valParms = '';
+ for ($i = 11; $i < (11 + $numParms); $i++)
+ {
+ $valParms .= "<li>" . str_replace('\n',
+ '<br />',
+ htmlentities($data[$i])) . "</li>\n";
}
}
-?>
- <table>
- <tr>
- <td>
-<?php echo $traceFile; ?><br />
- <strong><?php echo count($fullTrace); ?></strong> function calls in <strong><?php $l = end($fullTrace);
- echo $l['timeOnEntry']; ?> seconds</strong>, using <strong><?php echo $l['memoryOnEntry']; ?> MB</strong> of memory.
- </td>
- <td></td>
- <td style="vertical-align:bottom"><small>in = start func.<br />out = end func.</small></td>
- <td style="vertical-align:bottom"><small>in = start func.<br />out = end func.</small></td>
- </tr>
- <tr>
- <th>Function / File</th>
- <th>Line</th>
- <th>Time</th>
- <th>Memory</th>
- </tr>
-<?php
- foreach ($fullTrace as $trace) {
-?>
- <tr>
- <td style="padding-left:<?php echo ($trace['level'] * 10) ?>px">
-<?php if ($trace['type'] == 0) { ?><a target="_blank" href="http://php.net/<?php echo $trace['function']; ?>"><img src="images/native.png" alt="PHP " /></a><?php } else { ?><img src="images/user.png" alt="UDF " /><?php } ?><strong><?php if ($trace['type'] == 0) { ?>php::<?php } ?><?php echo $trace['function']; ?></strong><br />
- <small><?php echo $trace['filename']; ?></small>
- <span class="warning">
-<?php if ($trace['timeAlert']) { ?><br />Warning, time jump exceeds trigger! <?php echo $trace['timeAlert'];
- } ?>
- <?php if ($trace['memoryAlert']) {
- ?><br />Warning, memory jump exceeds trigger! <?php echo $trace['memoryAlert'];
- } ?>
- </span>
+ elseif (!empty($file))
+ {
+ $valParms = "<li>{$file}</li>";
+ }
+ else
+ {
+ $valParms = '';
+ }
+ $memory = round($memory / (1024 * 1024), 4);
+
+ break;
+
+ /**
+ * Other xdebug.trace_format
+ * @todo code for all types
+ */
+ default:
+
+ $strippedLine = preg_replace('(([\s]{2,}))', ' ',
+ trim($line));
+ list ($time, $memory) = explode(" ", $strippedLine);
+
+ $memory = round($memory / (1024 * 1024), 4);
+
+ $level = round(((strpos($line, '->') - strpos($line,
+ $memory) + strlen($memory))) / 2);
+
+ if ($level <= $previousLevel && isset($levelIds[$level]))
+ {
+ $fullTrace[$levelIds[$level]]['timeOnExit'] = $time;
+ $fullTrace[$levelIds[$level]]['memoryOnExit'] = $memory;
+ }
+ $id = ++$ids;
+ $levelIds[$level] = $id;
+ $previousLevel = $level;
+
+ $parts = array_map('trim', explode("->", $line, 2));
+ $parts = explode(" ", $parts[1]);
+ $function = $parts[0];
+ list($line, $file) = array_map('strrev',
+ explode(":",
+ strrev($parts[1]),
+ 2));
+ $filename = $file;
+ $point = 0;
+ $type = in_array(substr($function, 0,
+ strpos($function, "(")),
+ $defFn['internal']) ? 0 : 1;
+
+ $valParms = '';
+
+ break;
+ }
+
+ if (empty($function))
+ {
+ $fullTrace[$id]['timeOnExit'] = $time;
+ $fullTrace[$id]['memoryOnExit'] = $memory;
+ continue;
+ }
+
+
+
+// if (!empty($filename) and strpos('eyeOS/Loader', $filename) > 0)
+// {
+// continue;
+// }
+
+ if ($point == 0)
+ {
+ // starting function
+ $fullTrace[$id] = array('level' => $level,
+ 'id' => $id,
+ 'timeOnEntry' => $time,
+ 'memoryOnEntry' => $memory,
+ 'function' => $function,
+ 'type' => $type,
+ 'file' => $file,
+ 'filename' => $filename,
+ 'line' => $line,
+ 'valParms' => $valParms);
+
+ if (isset($lastMemory) and ($memory - $lastMemory) > $memJump)
+ {
+ $fullTrace[$id]['memoryAlert'] = $memory - $lastMemory;
+ }
+ else
+ {
+ $fullTrace[$id]['memoryAlert'] = false;
+ }
+
+
+ if (isset($lastMemory) and ($time - $lastTime) > $timeJump)
+ {
+ $fullTrace[$id]['timeAlert'] = $time - $lastTime;
+ }
+ else
+ {
+ $fullTrace[$id]['timeAlert'] = false;
+ }
+
+ $lastMemory = $memory;
+ $lastTime = $time;
+ }
+ else
+ {
+ $fullTrace[$id]['timeOnExit'] = $time;
+ $fullTrace[$id]['memoryOnExit'] = $memory;
+ }
+ }
+ ?>
+ <table>
+ <tr>
+ <td>
+ <?= $traceFile; ?><br />
+ <strong><?= count($fullTrace); ?></strong> function calls in <strong><?php $l = end($fullTrace);
+ echo $l['timeOnEntry']; ?> seconds</strong>, using <strong><?= $l['memoryOnEntry'] ?> MB</strong> of memory.
</td>
- <td class="digit line"><a href="#<?php echo $trace['line']; ?>"><?php echo $trace['line']; ?></a></td>
- <td class="digit" style="<?php if ($trace['timeAlert']) { ?>background:maroon;color:white<?php } ?>">in: <?php echo $trace['timeOnEntry']; ?><br />out: <?php echo $trace['timeOnExit']; ?></td>
- <td class="digit" style="<?php if ($trace['memoryAlert']) { ?>background:maroon;color:white<?php } ?>">in: <?php echo $trace['memoryOnEntry']; ?> MB<br />out: <?php echo $trace['memoryOnExit']; ?> MB</td>
+ <td></td>
+ <td style="vertical-align:bottom"><small>in = start func.<br />out = end func.</small></td>
+ <td style="vertical-align:bottom"><small>in = start func.<br />out = end func.</small></td>
</tr>
- <?php
+ <tr>
+ <th style="max-width: 70%">Function / File</th>
+ <th style="min-width: 8em;">Line</th>
+ <th style="min-width: 8em;">Time</th>
+ <th style="min-width: 8em;">Memory</th>
+ </tr>
+ <?php
+ foreach ($fullTrace as $trace)
+ {
+ /**
+ *
+ *
+ echo "<pre>";
+ var_dump($trace);
+ echo "</pre><hr>";
+ /**
+ */
+ ?>
+ <tr>
+ <td style="padding-left:<?php
+ if (isset($trace['level']))
+ {
+ echo $trace['level'] * 10;
+ }
+ else
+ {
+ echo '0';
+ }
+ ?>px">
+ <?php if (isset($trace['type']) and $trace['type'] == 0)
+ { ?><a target="_blank" href="http://php.net/<?= $trace['function'] ?>"><span class="native" title="PHP doc <?= $trace['function'] ?>">&#x261b; </span></a><?php
+ }
+ else
+ {
+ /**
+ * custom color identifier for ZendFramework methods
+ */
+ if (isset($trace['function']) and substr($trace['function'],
+ 0, 5) == 'Zend_')
+ {
+ $userFunction = 'Zend';
+ }
+ /**
+ * And all Corretge namespace classes and methods
+ */
+ elseif (isset($trace['function']) and substr($trace['function'],
+ 0,
+ $XDEBUG_TRACE_GUI_CUSTOM_NAMESPACE_LEN) == XDEBUG_TRACE_GUI_CUSTOM_NAMESPACE)
+ {
+ $userFunction = 'Corretge';
+ }
+ else
+ {
+ $userFunction = 'user';
+ }
+ ?><span class="<?= $userFunction ?>" title="UDF ">&#x261b; </span><?php } ?><strong><?php if (isset($trace['type']) and $trace['type'] == 0)
+ { ?>\<?php } ?><?= @$trace['function'] ?></strong><ul><?= @$trace['valParms'] ?></ul><br />
+ <small><?= @$trace['filename'] ?></small>
+ <span class="warning">
+ <?php
+ if (isset($trace['timeAlert']) and $trace['timeAlert'])
+ {
+ echo "<br />Warning, time jump exceeds trigger! {$trace['timeAlert']}";
+ }
+ if (isset($trace['memoryAlert']) and $trace['memoryAlert'])
+ {
+ echo "<br />Warning, memory jump exceeds trigger! {$trace['memoryAlert']}";
+ }
+ ?>
+ </span>
+
+ </td>
+ <td class="digit line">
+ <?php
+ if (isset($trace['line']))
+ {
+ echo "<a href=\"#{$trace['line']}\">{$trace['line']}</a>";
+ }
+ ?>
+ </td>
+ <td class="digit" style="<?php if (isset($trace['timeAlert']) and $trace['timeAlert'])
+ { ?>background:maroon;color:white<?php } ?>">in: <?= @$trace['timeOnEntry'] ?> s<br />out: <?= @$trace['timeOnExit'] ?> <br />
+ <?php
+ if (isset($trace['timeOnEntry']) and isset($trace['timeOnExit']))
+ {
+ $jTimeConsumit = ($trace['timeOnExit'] - $trace['timeOnEntry']) * 1000000;
+ echo number_format($jTimeConsumit, 0) . ' µs';
+ }
+ else
+ {
+ $jTimeConsumit = 0;
+ }
+ ?></td>
+ <td class="digit" style="<?php if (isset($trace['memoryAlert']) and $trace['memoryAlert'])
+ { ?>background:maroon;color:white<?php } ?>">in: <?= @$trace['memoryOnEntry'] ?> MB<br />out: <?= @$trace['memoryOnExit'] ?> MB<br />
+
+
+ <?php
+ if (isset($trace['memoryOnEntry']) and isset($trace['memoryOnExit']))
+ {
+ $jMemoryConsumit = ($trace['memoryOnExit'] - $trace['memoryOnEntry']) * 1000000;
+ echo number_format($jMemoryConsumit, 0) . ' B';
+ }
+ else
+ {
+ $jMemoryConsumit = 0;
+ }
+ ?>
+ </td>
+ </tr>
+ <?php
+ if (isset($trace) and isset($trace['function']))
+ {
+ if (isset($aSumary[$trace['function']]))
+ {
+ $aSumary[$trace['function']]['mem'] += $jMemoryConsumit;
+ $aSumary[$trace['function']]['tim'] += $jTimeConsumit;
+ $aSumary[$trace['function']]['cnt']++;
+ }
+ else
+ {
+ $aSumary[$trace['function']]['func'] = $trace['function'];
+ $aSumary[$trace['function']]['mem'] = $jMemoryConsumit;
+ $aSumary[$trace['function']]['tim'] = $jTimeConsumit;
+ $aSumary[$trace['function']]['cnt'] = 1;
}
- ?>
- </table>
- <?php
}
+
+ /**
+ * fem el sumari per files
+ */
+ if (isset($trace) and isset($trace['filename']))
+ {
+ if (isset($aSumaryS[$trace['filename']]))
+ {
+ $aSumaryS[$trace['filename']]['mem'] += $jMemoryConsumit;
+ $aSumaryS[$trace['filename']]['tim'] += $jTimeConsumit;
+ $aSumaryS[$trace['filename']]['cnt']++;
+ }
+ else
+ {
+ $aSumaryS[$trace['filename']]['filename'] = $trace['filename'];
+ $aSumaryS[$trace['filename']]['mem'] = $jMemoryConsumit;
+ $aSumaryS[$trace['filename']]['tim'] = $jTimeConsumit;
+ $aSumaryS[$trace['filename']]['cnt'] = 1;
+ }
+ }
+ }
+ ?>
+ </table>
+ <?php
+ }
+
+// usort($aSumary, 'aryComp');
+ unset($fullTrace);
+ usortByArrayKey($aSumary, 'tim', SORT_DESC);
+ usortByArrayKey($aSumaryS, 'tim', SORT_DESC);
+
+ echo "<a name=\"sumary\"></a><h2>Sumari de funcions per temps emprat</h2>
+ <table>
+ <tr>
+ <th>Function</th>
+ <th>times</th>
+ <th>sum Time</th>
+ <th>sum Memory</th>
+ <th>avg Time</th>
+ <th>avg Memory</th>
+</tr>
+ ";
+
+ foreach ($aSumary as $row)
+ {
+ if ($row['cnt'] != 0)
+ {
+
+ $jAvgTim = $row['tim'] / $row['cnt'];
+ $jAvgMem = $row['mem'] / $row['cnt'];
+ }
+ else
+ {
+ $jAvgTim = 0;
+ $jAvgMem = 0;
+ }
+
+ $row['cnt'] = number_format($row['cnt'], 0);
+ $row['tim'] = number_format($row['tim'], 0);
+ $row['mem'] = number_format($row['mem'], 0);
+
+ $jAvgMem = number_format($jAvgMem, 0);
+ $jAvgTim = number_format($jAvgTim, 0);
+
+ echo "<tr>
+ <td>{$row['func']}</td>
+ <td class='digit'>{$row['cnt']}</td>
+ <td class='digit'>{$row['tim']}</td>
+ <td class='digit'>{$row['mem']}</td>
+ <td class='digit'>{$jAvgTim}</td>
+ <td class='digit'>{$jAvgMem}</td>
+
+ </tr>";
+ }
+
+
+ echo "</table>";
+
+
+
+
+ echo "<a name=\"sumary\"></a><h2>Sumari d'scripts per temps emprat</h2>
+ <table>
+ <tr>
+ <th>Script</th>
+ <th>instructions</th>
+ <th>sum Time</th>
+ <th>sum Memory</th>
+ <th>avg Time per inst</th>
+ <th>avg Memory per inst</th>
+ </tr>
+ ";
+
+ foreach ($aSumaryS as $row)
+ {
+ if ($row['cnt'] != 0)
+ {
+
+ $jAvgTim = $row['tim'] / $row['cnt'];
+ $jAvgMem = $row['mem'] / $row['cnt'];
+ }
+ else
+ {
+ $jAvgTim = 0;
+ $jAvgMem = 0;
+ }
+
+ $row['cnt'] = number_format($row['cnt'], 0);
+ $row['mem'] = number_format($row['mem'], 0);
+ $row['tim'] = number_format($row['tim'], 0);
+ $jAvgMem = number_format($jAvgMem, 0);
+ $jAvgTim = number_format($jAvgTim, 0);
+
+ echo "<tr>
+ <td>{$row['filename']}</td>
+ <td class='digit'>{$row['cnt']}</td>
+ <td class='digit'>{$row['tim']}</td>
+ <td class='digit'>{$row['mem']}</td>
+ <td class='digit'>{$jAvgTim}</td>
+ <td class='digit'>{$jAvgMem}</td>
+ </tr>";
+ }
+
+
+ echo "</table>";
?>
<script type="text/javascript">
View
13 xdebug.ini
@@ -0,0 +1,13 @@
+; Place this file in /etc/php5/conf.d
+extension=xdebug.so
+xdebug.auto_trace=On
+xdebug.trace_format=1
+xdebug.trace_output_dir=/var/log/php
+xdebug.show_mem_delta=On
+xdebug.var_display_max_data=128
+xdebug.collect_params=4
+xdebug.collect_return=On
+xdebug.trace_options=1
+xdebug.trace_output_name= %H-%p.trace
+xdebug.profiler_output_name = %s.%t.profile
+xdebug.profiler_output_dir=/var/log/php
Please sign in to comment.
Something went wrong with that request. Please try again.