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() ...