I'm Floris And that's all there is to it really
11 Jul '12
Measure memory usage in PHP
Hopefully this explains a simple method of measuring memory usage in PHP.
Here's an example, where I sleep the script for ~ 10 seconds.
And how it looks in the browser: (I've added <pre> around it for easy reading)
You can find more examples and full documentation on the http://php.net/memory_get_usage web site.
$time = microtime(TRUE); $mem = memory_get_usage(); /** * Put the code here that you want to measure **/ print_r(array( 'memory' => (memory_get_usage() - $mem) / (1024 * 1024), 'seconds' => microtime(TRUE) - $time ));
Here's an example, where I sleep the script for ~ 10 seconds.
And how it looks in the browser: (I've added <pre> around it for easy reading)
You can find more examples and full documentation on the http://php.net/memory_get_usage web site.
Latest Articles
- 2012
- New Year's Resolution 2013
- The end of the world, again
- Network upgrade 2012
- Technological Singularity
- Those old keyboards
- Thinking about the iPhone5
- Creepy iPhone Spider Mount
- A Sasha Update
- Password Management
- Screen Protection for the iPad
- Mac Pro upgrade
- Roughing up the iPad
- Apple Store app feedback
- Tutorial: PHP function handyDate()
- The best Apple device to buy
- iMac Upgrade