forked from wesleyegberto/java-new-features
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathProfilingTest.java
More file actions
24 lines (22 loc) · 734 Bytes
/
Copy pathProfilingTest.java
File metadata and controls
24 lines (22 loc) · 734 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
import java.util.*;
import java.util.stream.*;
/**
* Compile: `javac ProfilingTest.java`
* Test AOT cache with two-step:
* * Record mode: `java -XX:AOTMode=record -XX:AOTConfiguration=app.aotconf ProfilingTest`
* * Create mode: `java -XX:AOTMode=create -XX:AOTConfiguration=app.aotconf -XX:AOTCache=app.aot`
* * Run with AOT cache: `java -XX:AOTCache=app.aot ProfilingTest`
*/
public class ProfilingTest {
static String greeting(int n) {
var words = List.of("Hello", "" + n, "world!");
return words.stream()
.filter(w -> !w.contains("0"))
.collect(Collectors.joining(", "));
}
public static void main(String... args) {
for (int i = 0; i < 100_000; i++)
greeting(i);
System.out.println(greeting(0));
}
}