Clone
Pepper Lebeck-Jobe <pepper@gradle.com>
committed
on 22 Oct 16
Add TimeProvider.currentTimeForDuration and use it
There were many places we were measuring a duration by comparing
`System.currentTimeMilli… Show more
Add TimeProvider.currentTimeForDuration and use it

There were many places we were measuring a duration by comparing

`System.currentTimeMillis()` at some start and end times. This is a

known anti-pattern which is subject to incorrect duration measurements

due to how clock skew affects the implementation of that function.

The new `currentTimeForDuration()` method uses `System.nanoTime()` which

is much more reliable for measuring durations within a single thread of

control in a single process.

Replacing our uses of `System.currentTimeMillis()` with

`currentTimeForDuration()` will make Gradle and our tests much more

reliable.

In service of issue #740

Show less

green-master + 411 more