Skip to content

Instantly share code, notes, and snippets.

@shevron
Forked from anonymous/test.php
Last active August 29, 2015 14:01

Revisions

  1. shevron revised this gist May 25, 2014. 1 changed file with 2 additions and 1 deletion.
    3 changes: 2 additions & 1 deletion test.php
    Original file line number Diff line number Diff line change
    @@ -15,6 +15,7 @@
    function write_data($data)
    {
    $outfp = fopen('/dev/null', 'w');
    fwrite($outfp, $data . "\n");
    fwrite($outfp, $data);
    fwrite($outfp, "\n");
    fclose($outfp);
    }
  2. @invalid-email-address Anonymous created this gist May 25, 2014.
    20 changes: 20 additions & 0 deletions test.php
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,20 @@
    <?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);
    }