OnJava8-Examples/validating/BadMicroBenchmark.java

21 lines
595 B
Java
Raw Normal View History

2016-08-29 07:27:53 -06:00
// validating/BadMicroBenchmark.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.*;
public class BadMicroBenchmark {
2016-09-28 12:54:00 -06:00
static final int SIZE = 250_000_000;
2016-01-25 18:05:55 -08:00
public static void main(String[] args) {
long[] la = new long[SIZE];
System.out.print("setAll: ");
Time.it(() -> Arrays.setAll(la, n -> n));
2016-01-25 18:05:55 -08:00
System.out.print("parallelSetAll: ");
Time.it(() -> Arrays.parallelSetAll(la, n -> n));
2016-01-25 18:05:55 -08:00
}
}
/* Output:
2016-09-28 12:54:00 -06:00
setAll: 272
parallelSetAll: 301
2016-01-25 18:05:55 -08:00
*/