Created
July 27, 2017 12:47
-
-
Save mirfilip/daefd07cc22b703fe807ce041339f30a to your computer and use it in GitHub Desktop.
Testing memory usage of Feed-IO
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 | |
require __DIR__."/vendor/autoload.php"; | |
$client = new GuzzleHttp\Client(); | |
$feed = $argv[1]; | |
echo "Reading $feed" . PHP_EOL . PHP_EOL; | |
print_mem_usage('before request'); | |
$res = $client->request('GET', $feed); | |
print_mem_usage('after request'); | |
echo "stream size (PSR way) : {$res->getBody()->getSize()}" . PHP_EOL; | |
print_mem_usage('after reading stream size (PSR way)'); | |
echo "stream size (strlen) : " . strlen($res->getBody()) . PHP_EOL; | |
print_mem_usage('after reading stream size (strlen)'); | |
function print_mem_usage($step) | |
{ | |
echo "{$step}" . PHP_EOL; | |
echo "allocated to PHP: " . memory_get_usage(true) . PHP_EOL; | |
echo "Used by PHP: " . memory_get_usage() . PHP_EOL; | |
echo "Used at peak: " . memory_get_peak_usage() . PHP_EOL; | |
echo "------" . PHP_EOL; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment