test: Only measure times before/after loop, not in the loop

This seems to produce more consistent results.