helper function for computing execution time. fix a bug in test case