endTime should be computed here, as printing the results may add non-trivial overhead.