Skip to content

Instantly share code, notes, and snippets.

@daniellockyer
Last active December 14, 2019 12:10
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save daniellockyer/263278b84f680258c5761f16bea900d2 to your computer and use it in GitHub Desktop.
Save daniellockyer/263278b84f680258c5761f16bea900d2 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>
@rmetzler
Copy link

I try to check this out, very much appreciated.

I wonder what license this code has?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment