Profiling manually with Blackfire.io

We will start by profiling manually two PHP scripts in order to better understand how useful and powerful the Blackfire tools can be. We will use the following script, which can be found in our repository (chap2pre.php):

<?php function getDiskUsage(string $directory) { $handle = popen("cd $directory && du -ch --exclude='./.*'", 'r'); $du = stream_get_contents($handle); pclose($handle); return $du; } function getDirList(string $directory, string &$du) { $result = getDiskUsage($directory); $du = empty($du) ? '<br />' . preg_replace('/\n+/', '<br />', $result) : $du; $fileList = []; $iterator = new RecursiveDirectoryIterator($directory, FilesystemIterator::SKIP_DOTS); foreach($iterator as $entry) { if (!$entry->isDir() ...

Get Mastering The Faster Web with PHP, MySQL, and JavaScript now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.