There can be many other ways to solve your problem, but here is one approach that you may use ...
Since performance varies from machine to machine, it is somewhat hard to predict beforehand how long it may take to complete. So hard-coding the time estimate into the codes may not be the best...