That might take 30 seconds or so to accomplish. Assuming the engine remains dead, it will take about another 30 to 45 seconds to configure for an off-airport landing, shutting off fuel and nonessential electrical equipment. The balance of the time will be spent flying the airplane to a suitable spot, hopefully, and sending a Mayday message. It's busy, to be sure, but not a time to rush. It also makes the case for flying as high above the terrain as reasonable for conditions.
More altitude simply means more time.
Making haste in search of the solution frequently creates more trouble. Mispositioning a fuel selector to Off will ensure that an engine that was running rough because of a lean mixture will become very smooth and very quiet. The timing could be interesting too, because the engine may run for a minute or so while it burns up the residual fuel in the lines. If, in the interim, we have continued our quest for the problem, going back to reset the fuel selector may not seem like an obvious solution. Mysteries like this can be avoided with a methodical approach.