Half an hour ago already answered a similar question.
At the very start put
and then scatter on the code
echo 'Mark 1 - '.round( (microtime(true) - TIMESTART), 5).' sec'.PHP_EOL;
echo 'Label 2 - '.round( (microtime(true) - TIMESTART), 5).' sec'.PHP_EOL;
and when you access the page you have something like:
Mark 1 - 0.003 sec (from start run)
Mark 2 - 4.531 sec (from start run)
Mark 3 - 4.582 sec (from start run)
of which will become clear between mark 1 and mark 2 that was treated with 4.5 seconds.
Narrow the search space by shifting the labels until you find the problem.