caculate time of function execution