2016-08-29 07:27:53 -06:00
|
|
|
// validating/Time.java
|
2016-01-25 18:05:55 -08:00
|
|
|
// (c)2016 MindView LLC: see Copyright.txt
|
|
|
|
// We make no guarantees that this code is fit for any purpose.
|
2016-09-23 13:23:35 -06:00
|
|
|
// Visit http://OnJava8.com for more book information.
|
2016-01-25 18:05:55 -08:00
|
|
|
import java.util.concurrent.*;
|
|
|
|
|
2016-08-23 09:33:05 -06:00
|
|
|
public interface Time {
|
|
|
|
static long it(Runnable test) {
|
2016-01-25 18:05:55 -08:00
|
|
|
long start = System.nanoTime();
|
|
|
|
test.run();
|
|
|
|
long delta = System.nanoTime() - start;
|
|
|
|
long millis = TimeUnit.NANOSECONDS.toMillis(delta);
|
|
|
|
System.out.println(millis);
|
|
|
|
return millis;
|
|
|
|
}
|
|
|
|
}
|