Created
July 22, 2017 21:56
-
-
Save Bujhm/020c50074d5600aaf76e52ec8bbadfa4 to your computer and use it in GitHub Desktop.
[CheckMemoryConsumption проверка занимаемой памяти (basic implementation))
This file contains hidden or 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
/** | |
* [CheckMemoryConsumption проверка занимаемой памяти приложением] | |
* @param string $state [состояние одно из возможных: initial,final,peak] | |
* @return string | |
*/ | |
public static function CheckMemoryConsumption($state = 'initial') | |
{ | |
$memorySizeConsumptionString = ''; | |
switch ($state){ | |
case "initial": | |
$memorySizeConsumptionString = "Initial: ".number_format(memory_get_usage(), 0, ',', ' ')." bytes \n"; | |
/* prints | |
Initial: 361400 bytes | |
*/ | |
break; | |
case "final": | |
$memorySizeConsumptionString = "Final: ".number_format(memory_get_usage(), 0, ',', ' ')." bytes \n"; | |
/* prints | |
Final: 885912 bytes | |
*/ | |
break; | |
case "peak": | |
$memorySizeConsumptionString = "Peak: ".number_format(memory_get_peak_usage(), 0, ',', ' ')." bytes \n"; | |
/* prints | |
Peak: 13687072 bytes | |
*/ | |
default: | |
break; | |
} | |
return $memorySizeConsumptionString; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment