Created
March 25, 2024 07:04
-
-
Save saroarhossain57/835b45df204dba5cd5bc7c1e9428098f to your computer and use it in GitHub Desktop.
Get and Analysis Memory and Execution time 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 | |
$start_mem = memory_get_usage(); | |
$start = hrtime(true); | |
$array = range(1, 100000); | |
$end = hrtime(true); | |
$end_mem = memory_get_usage(); | |
$mem_usage = $end_mem - $start_mem; | |
// Calculate the execution time | |
$execution_time = ( $end - $start ) / 1000000; | |
echo $mem_usage . " Bytes or " . $mem_usage / 1000000 . " MB \n"; | |
echo "Execution Time: " . $execution_time . " MS"; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment