improved timeMeasure()