Skip to content

Instantly share code, notes, and snippets.

@shevron
shevron / test.php
Last active August 29, 2015 14:01 — forked from anonymous/test.php
A better way to write to /dev/null
<?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";