Created
June 14, 2011 21:39
-
-
Save rgantt/1025970 to your computer and use it in GitHub Desktop.
dead simple profiling in PHP 5.3
This file contains 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 | |
function profile( $message, $closure ) { | |
$start = microtime( true ); | |
$closure( $start ); | |
$duration = ( microtime( true ) - $start ); | |
return "{$message} {$duration}\n"; | |
} |
This file contains 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 | |
require_once "profile.php"; | |
echo profile( "Looping!", function( $start ) { | |
$n = 0; | |
for( $i = 0; $i < 1000; $i++ ) { | |
$n += $i; | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment