I have created an algorithm and I need to run it with different datasets, and then record the running time the algorithm took for each datasets.

I understand that shell script is one way to do it. But is it possible to have a time out option? For example, if the algorithm took more than an hour on a dataset and it had not finish running, can I set a time out and make the algorithm to process on the next dataset?