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: ");
|
2016-08-23 09:33:05 -06:00
|
|
|
Time.it(() -> Arrays.setAll(la, n -> n));
|
2016-01-25 18:05:55 -08:00
|
|
|
System.out.print("parallelSetAll: ");
|
2016-08-23 09:33:05 -06:00
|
|
|
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
|
|
|
*/
|