Skip to content

Instantly share code, notes, and snippets.

@rmetzler
Forked from daniellockyer/xdebugfg.php
Created December 14, 2019 12:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rmetzler/24cffbb3093d7b6029fb08c841d3e5f1 to your computer and use it in GitHub Desktop.
Save rmetzler/24cffbb3093d7b6029fb08c841d3e5f1 to your computer and use it in GitHub Desktop.
<!DOCTYPE html>
<html>
<head>
<title>XDebug Flame Graph</title>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=2" />
<style>
label {cursor: pointer;}
svg{width:100%;}
</style>
</head>
<body>
<h1>XDebug Flame Graph</h1>
<form method="POST" class="load">
<label for="file">File:</label>
<select name="file" id="file">
<?php
$dir = ini_get('xdebug.trace_output_dir');
if (!$dir) $dir = '/tmp/';
$files = glob("$dir/*.xt");
foreach ($files as $file) {
$checked = ($file == $_REQUEST['file']) ? 'selected="selected"' : '';
echo '<option value="' . htmlspecialchars($file) . '" '.$checked.'>' . htmlspecialchars(basename($file)) . '</option>';
}
?>
</select>
<button type="submit">Load</button>
<br/>
<p>Files from <code>xdebug.trace_output_dir = <?php echo htmlspecialchars($dir) ?></code></p>
</form>
<?php
if (!empty($_REQUEST['file'])) {
$file = $_REQUEST['file'];
if (!file_exists($file)) { echo "input file does not exist"; return; }
if (!is_readable($file)) { echo "cannot read input file"; return; }
passthru(__DIR__.'/FlameGraph/stackcollapse-xdebug.php '.$file.' | '.__DIR__.'/FlameGraph/flamegraph.pl');
}
?>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment