in reply to calculate run time

I think you want to look at the alarm function:

alarm SECONDS alarm Arranges to have a SIGALRM delivered to this process after the specified number of wallclock seconds have elapsed. If SECONDS is not specified, the value stored in $_ is used.

-- Dan