calculate execution time of function