Skip to content

Instantly share code, notes, and snippets.

@brianteachman
Created October 1, 2012 22:41
Show Gist options
  • Save brianteachman/3814937 to your computer and use it in GitHub Desktop.
Save brianteachman/3814937 to your computer and use it in GitHub Desktop.
PHP timimg script using microtime() and BC Math
#!/usr/bin/php
<?php
$profile = function() {
static $start = '0';
list($timestamp, $microseconds) = split(' ', microtime());
$current = bcadd($timestamp, $microseconds, 4);
if ($start === '0') {
$start = $current;
return;
}
return bcsub($current, $start, 4);
};
$profile();
usleep(1000000); // 1 second
echo $profile() . ' seconds' . PHP_EOL;
?>
@ryross
Copy link

ryross commented Jun 12, 2015

This is exactly what I was looking for. Thanks :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment