Guest User

PHP readfile memory usage test

a guest
Apr 30th, 2012
140
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.58 KB | None | 0 0
  1. <?php
  2.  
  3. if (!file_exists('foo.dat')) {
  4.     /* If the file to be read from disk doesn't exist create it */
  5.     file_put_contents('foo.dat', str_repeat(0x00,1024*1024*10));
  6. }
  7.  
  8. if (ini_get('output_buffering')) die('Please turn off output buffering...');
  9. $mem_start = memory_get_usage(); /* Store the memory usage here */
  10.  
  11. readfile('foo.dat'); /* Read the file into output */
  12. $mem_end = memory_get_usage(); /* Store the memory usage here */
  13. $mem_peak = memory_get_peak_usage();
  14. echo "<pre>Memory started at: $mem_start\nMemory ended at: $mem_end\nMemory peaked at: $mem_peak</pre>";
  15.  
  16. ?>
Advertisement
Add Comment
Please, Sign In to add comment