Created
May 25, 2014 07:11
-
-
Save anonymous/a130843308a6b0c7e202 to your computer and use it in GitHub Desktop.
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 | |
// 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