Skip to content

Instantly share code, notes, and snippets.

@uzulla
Created July 13, 2021 07:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save uzulla/19ed1fe9331b01ddba2ef22989bafc64 to your computer and use it in GitHub Desktop.
Save uzulla/19ed1fe9331b01ddba2ef22989bafc64 to your computer and use it in GitHub Desktop.
<?php
function stopwatch($str = null)
{
static $time = null;
if (is_null($str)) {
$time = microtime(true);
} else {
echo $str . ( microtime(true) - $time) . "sec" . PHP_EOL;
$time = 0;
}
}
stopwatch();
sleep(1);
stopwatch();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment