OnJava8-Examples/validating/BadMicroBenchmark.java

21 lines
611 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.
// Visit http://mindviewinc.com/Books/OnJava/ for more book information.
import java.util.*;
public class BadMicroBenchmark {
static final int SIZE = 20_000_000;
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-07-27 11:12:11 -06:00
setAll: 75
parallelSetAll: 110
2016-01-25 18:05:55 -08:00
*/