OnJava8-Examples/validating/BadMicroBenchmark2.java

22 lines
641 B
Java
Raw Normal View History

2016-08-29 07:27:53 -06:00
// validating/BadMicroBenchmark2.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.
// Visit http://mindviewinc.com/Books/OnJava/ for more book information.
// Reversing the test order
import java.util.*;
public class BadMicroBenchmark2 {
static final int SIZE = 20_000_000;
public static void main(String[] args) {
long[] la = new long[SIZE];
System.out.print("parallelSetAll: ");
Time.it(() -> Arrays.parallelSetAll(la, n -> n));
2016-01-25 18:05:55 -08:00
System.out.print("setAll: ");
Time.it(() -> Arrays.setAll(la, n -> n));
2016-01-25 18:05:55 -08:00
}
}
/* Output:
2016-07-27 11:12:11 -06:00
parallelSetAll: 68
setAll: 196
2016-01-25 18:05:55 -08:00
*/