Skip to content

Instantly share code, notes, and snippets.

Created May 25, 2014 07:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save anonymous/a130843308a6b0c7e202 to your computer and use it in GitHub Desktop.
Save anonymous/a130843308a6b0c7e202 to your computer and use it in GitHub Desktop.
<?php
// Get 10mb of data from /dev/zero
$infp = fopen('/dev/zero', 'r');
$data = fread($infp, 1024 * 1024 * 10);
fclose($infp);
write_data($data);
echo "Peak memory usage: ", number_format(memory_get_peak_usage()), " bytes\n";
/**
* Bad example of how to write some data to /dev/null
*/
function write_data($data)
{
$outfp = fopen('/dev/null', 'w');
fwrite($outfp, $data . "\n");
fclose($outfp);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment