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

Method main

validating/BadMicroBenchmark.java:11–24  ·  view source on GitHub ↗
(String[] args)

Source from the content-addressed store, hash-verified

9public class BadMicroBenchmark {
10 static final int SIZE = 250_000_000;
11 public static void main(String[] args) {
12 try { // For machines with insufficient memory
13 long[] la = new long[SIZE];
14 System.out.println("setAll: " +
15 Timer.duration(() ->
16 Arrays.setAll(la, n -> n)));
17 System.out.println("parallelSetAll: " +
18 Timer.duration(() ->
19 Arrays.parallelSetAll(la, n -> n)));
20 } catch(OutOfMemoryError e) {
21 System.out.println("Insufficient memory");
22 System.exit(0);
23 }
24 }
25}
26/* Output:
27Insufficient memory

Callers

nothing calls this directly

Calls 3

durationMethod · 0.95
setAllMethod · 0.45
parallelSetAllMethod · 0.45

Tested by

no test coverage detected