Created
May 25, 2015 04:52
-
-
Save tucq88/1a751c8947738ccf7fc9 to your computer and use it in GitHub Desktop.
Finding bottlenecks in your PHP code (From : http://www.codediesel.com/testing/finding-bottlenecks-in-your-php-code)
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
| $fplog = fopen("logb.txt", "a+"); | |
| $lastlogtime = time(); | |
| function log_time($logtext) | |
| { | |
| global $fplog, $lastlogtime; | |
| $nowtime = time(); | |
| $diff = $nowtime - $lastlogtime; | |
| fwrite($fplog, sprintf("%-30s | %-30s | %-3d", $logtext, date('F Y h:i:s A', $nowtime), $diff) . PHP_EOL); | |
| $lastlogtime = $nowtime; | |
| } | |
| log_time("Start"); | |
| . | |
| .// code | |
| . | |
| log_time("CertainActionController"); | |
| . | |
| ..// code | |
| . | |
| log_time("AfterActionController"); | |
| . | |
| ..// code | |
| . | |
| log_time("AfterLastCodeBlock"); | |
| fwrite($fplog, PHP_EOL . "----------------------" . PHP_EOL); | |
| fclose($fplog); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment