Feat: calculate and log time taken for each project

This commit is contained in:
Damodar Lohani 2025-03-12 10:00:07 +00:00
parent d4dd7fb757
commit d77940d22f

View file

@ -77,7 +77,21 @@ class StatsResources extends Action
// Reset documents for each job
$this->documents = [];
$startTime = microtime(true);
$this->countForProject($dbForPlatform, $getLogsDB, $getProjectDB, $project);
$endTime = microtime(true);
$executionTime = $endTime - $startTime;
Console::info('Project: ' . $project->getId() . '(' . $project->getInternalId() . ') aggregated in ' . $this->formatTime($executionTime) .'');
}
public function formatTime($microseconds)
{
$seconds = $microseconds / 1000000; // Convert microseconds to seconds
$hours = floor($seconds / 3600);
$minutes = floor(($seconds % 3600) / 60);
$remainingSeconds = $seconds % 60;
return sprintf('%02d:%02d:%06.3f', $hours, $minutes, $remainingSeconds);
}