Skip to content

Instantly share code, notes, and snippets.

@rgantt
Created June 14, 2011 21:39
Show Gist options
  • Save rgantt/1025970 to your computer and use it in GitHub Desktop.
Save rgantt/1025970 to your computer and use it in GitHub Desktop.
dead simple profiling in PHP 5.3
<?php
function profile( $message, $closure ) {
$start = microtime( true );
$closure( $start );
$duration = ( microtime( true ) - $start );
return "{$message} {$duration}\n";
}
<?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