Skip to content

Commit

Permalink
ResultCacheManager: output restore time in debug mode
Browse files Browse the repository at this point in the history
  • Loading branch information
janedbal committed Jul 11, 2024
1 parent 146d3ba commit 024c2a4
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/Analyser/ResultCache/ResultCacheManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@
use function is_array;
use function is_file;
use function ksort;
use function microtime;
use function round;
use function sha1_file;
use function sort;
use function sprintf;
Expand Down Expand Up @@ -88,6 +90,7 @@ public function __construct(
*/
public function restore(array $allAnalysedFiles, bool $debug, bool $onlyFiles, ?array $projectConfigArray, Output $output): ResultCache
{
$startTime = microtime(true);
if ($debug) {
if ($output->isDebug()) {
$output->writeLineFormatted('Result cache not used because of debug mode.');
Expand Down Expand Up @@ -285,8 +288,10 @@ public function restore(array $allAnalysedFiles, bool $debug, bool $onlyFiles, ?
$filesToAnalyseCount = count($filesToAnalyse);

if ($output->isDebug()) {
$elapsed = microtime(true) - $startTime;
$output->writeLineFormatted(sprintf(
'Result cache restored. %d %s will be reanalysed.',
'Result cache restored in %f seconds. %d %s will be reanalysed.',
round($elapsed, 1),
$filesToAnalyseCount,
$filesToAnalyseCount === 1 ? 'file' : 'files',
));
Expand Down

0 comments on commit 024c2a4

Please sign in to comment.