Skip to content

Instantly share code, notes, and snippets.

@ircmaxell
Created March 21, 2014 23:11
Show Gist options
  • Select an option

  • Save ircmaxell/9698412 to your computer and use it in GitHub Desktop.

Select an option

Save ircmaxell/9698412 to your computer and use it in GitHub Desktop.
Tick Profiling
<?php
declare(ticks=1);
$__stack = [];
function getArrayKey(array $haystack, $needle) {
return isset($haystack[$needle]) ? $haystack[$needle] : '';
}
register_tick_function(function() {
global $__stack;
$bt = debug_backtrace(0, 1);
if (isset($bt[0])) {
$b = $bt[0];
$__stack[] = [
"class" => getArrayKey($b, "class"),
"type" => getArrayKey($b, "type"),
"func" => getArrayKey($b, "function"),
"line" => getArrayKey($b, "line"),
"file" => getArrayKey($b, "file"),
"mem" => memory_get_usage(),
"time" => microtime(true),
];
}
});
$app = require_once("bootstrap.php");
$app->run();
echo json_encode($__stack);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment