computing elapsed time for both cases