Created
April 8, 2026 18:49
-
-
Save ricardo-dlc/8ddc4c93ddb1c7ecbbb2cf25760dcb9b to your computer and use it in GitHub Desktop.
A lightweight PHP performance profiling helper built with closures.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?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