MCPcopy Index your code
hub / github.com/BruceEckel/OnJava8-Examples / main

Method main

validating/BadMicroBenchmark2.java:12–28  ·  view source on GitHub ↗
(String[] args)

Source from the content-addressed store, hash-verified

10 // SIZE reduced to make it run faster:
11 static final int SIZE = 5_000_000;
12 public static void main(String[] args) {
13 long[] la = new long[SIZE];
14 Random r = new Random();
15 System.out.println("parallelSetAll: " +
16 Timer.duration(() ->
17 Arrays.parallelSetAll(la, n -> r.nextLong())));
18 System.out.println("setAll: " +
19 Timer.duration(() ->
20 Arrays.setAll(la, n -> r.nextLong())));
21 SplittableRandom sr = new SplittableRandom();
22 System.out.println("parallelSetAll: " +
23 Timer.duration(() ->
24 Arrays.parallelSetAll(la, n -> sr.nextLong())));
25 System.out.println("setAll: " +
26 Timer.duration(() ->
27 Arrays.setAll(la, n -> sr.nextLong())));
28 }
29}
30/* Output:
31parallelSetAll: 1008

Callers

nothing calls this directly

Calls 3

durationMethod · 0.95
parallelSetAllMethod · 0.45
setAllMethod · 0.45

Tested by

no test coverage detected