Skip to content

Instantly share code, notes, and snippets.

@craigvantonder
Created December 18, 2016 12:07
Show Gist options
  • Save craigvantonder/ca4535bfbb2c7da516fbbdc0e004cdac to your computer and use it in GitHub Desktop.
Save craigvantonder/ca4535bfbb2c7da516fbbdc0e004cdac to your computer and use it in GitHub Desktop.
Calculate the process runtime in PHP
<?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