Created
December 18, 2016 12:07
-
-
Save craigvantonder/ca4535bfbb2c7da516fbbdc0e004cdac to your computer and use it in GitHub Desktop.
Calculate the process runtime in PHP
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 | |
$process_start_time; | |
$process_end_time; | |
$process_runtime; | |
// Capture process start time | |
list($usec, $sec) = explode(' ', microtime()); | |
// Store the start time | |
$process_start_time = (float) $sec + (float) $usec; | |
// Capture process end time | |
list($usec, $sec) = explode(' ', microtime()); | |
// Store the end time | |
$process_end_time = (float) $sec + (float) $usec; | |
// Calculate process runtime | |
$process_runtime = round($process_end_time - $process_start_time, 5); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment