- microtime: documentation ( source)
- stream_set_blocking: documentation ( source)
- fread: documentation ( source)
- fopen: documentation ( source)
<?php
$start = microtime( true );
$fp = fopen('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVQYV2NgYAAAAAMAAWgmWQ0AAAAASUVORK5CYII=', 'r' );
$open = microtime( true );
stream_set_blocking( $fp, 1 );
$block = microtime( true );
$data = fread( $fp, 2048 );
$read = microtime( true );
// the time taken to open the url
echo "Open: " . ($open-$start) . "\n";
// the time taken to set the stream to blocking
echo "Block: " . ($block-$open) . "\n";
// the time taken to read from the the stream
echo "Read: " . ($read-$block) . "\n";
// the amount of data read
echo "Data Read: " . strlen( $data ) . "\n";