Skip to content

Instantly share code, notes, and snippets.

@ricardo-dlc
Created April 8, 2026 18:49
Show Gist options
  • Select an option

  • Save ricardo-dlc/8ddc4c93ddb1c7ecbbb2cf25760dcb9b to your computer and use it in GitHub Desktop.

Select an option

Save ricardo-dlc/8ddc4c93ddb1c7ecbbb2cf25760dcb9b to your computer and use it in GitHub Desktop.
A lightweight PHP performance profiling helper built with closures.
<?php
$_perf = (static function (): \Closure {
$last = $start = microtime(true);
return static function (string $label) use (&$last, $start): void {
$now = microtime(true);
error_log(sprintf('[perf] %-28s %6.3fs (total %6.3fs)', $label . ':', $now - $last, $now - $start));
$last = $now;
};
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment