Skip to content

Instantly share code, notes, and snippets.

@SergejIsbrecht
Last active January 13, 2019 02:03
Show Gist options
  • Save SergejIsbrecht/a038d7b3b8323311ee8958e3dc344a77 to your computer and use it in GitHub Desktop.
Save SergejIsbrecht/a038d7b3b8323311ee8958e3dc344a77 to your computer and use it in GitHub Desktop.
GraalTesting
-rw-rw-r-- 1 sergej sergej 75191424 Jan 13 02:16 big2.txt (Luther Bible)
Linux sergej-P50 4.18.0-13-generic #14-Ubuntu SMP Wed Dec 5 09:04:24 UTC 2018 x86_64 x86_64 x86_64 GNU/Linux
// Graal-1.0.0-RC10 OpenJDK
sergej@sergej-P50:~/Downloads$ lscpu
Architecture: x86_64
CPU op-mode(s): 32-bit, 64-bit
Byte Order: Little Endian
CPU(s): 8
On-line CPU(s) list: 0-7
Thread(s) per core: 2
Core(s) per socket: 4
Socket(s): 1
NUMA node(s): 1
Vendor ID: GenuineIntel
CPU family: 6
Model: 94
Model name: Intel(R) Xeon(R) CPU E3-1535M v5 @ 2.90GHz
Stepping: 3
CPU MHz: 1924.569
CPU max MHz: 3800,0000
CPU min MHz: 800,0000
BogoMIPS: 5808.00
Virtualization: VT-x
L1d cache: 32K
L1i cache: 32K
L2 cache: 256K
L3 cache: 8192K
NUMA node0 CPU(s): 0-7
---
sergej@sergej-P50:~/Development/GitHub/GraalVMTest/oracleIssue/src/main/java$ /usr/bin/time -v /home/sergej/.gradle/caches/com.palantir.graal/1.0.0-rc10/graalvm-ce-1.0.0-rc10/bin/java TopTen ~/Downloads/big2.txt
und = 742224
der = 300752
die = 265888
da = 215936
zu = 161360
sie = 157024
den = 140000
er = 139776
das = 139760
ich = 129824
Command being timed: "/home/sergej/.gradle/caches/com.palantir.graal/1.0.0-rc10/graalvm-ce-1.0.0-rc10/bin/java TopTen /home/sergej/Downloads/big2.txt"
User time (seconds): 16.56
System time (seconds): 0.46
Percent of CPU this job got: 160%
Elapsed (wall clock) time (h:mm:ss or m:ss): 0:10.61
Average shared text size (kbytes): 0
Average unshared data size (kbytes): 0
Average stack size (kbytes): 0
Average total size (kbytes): 0
Maximum resident set size (kbytes): 1339556
Average resident set size (kbytes): 0
Major (requiring I/O) page faults: 0
Minor (reclaiming a frame) page faults: 333170
Voluntary context switches: 5955
Involuntary context switches: 63
Swaps: 0
File system inputs: 0
File system outputs: 64
Socket messages sent: 0
Socket messages received: 0
Signals delivered: 0
Page size (bytes): 4096
Exit status: 0
// native-image
sergej@sergej-P50:~/Development/GitHub/GraalVMTest/oracleIssue/src/main/java$ /usr/bin/time -v ~/Development/GitHub/GraalVMTest/oracleIssue/build/graal/hello-world ~/Downloads/big2.txt
und = 742224
der = 300752
die = 265888
da = 215936
zu = 161360
sie = 157024
den = 140000
er = 139776
das = 139760
ich = 129824
Command being timed: "/home/sergej/Development/GitHub/GraalVMTest/oracleIssue/build/graal/hello-world /home/sergej/Downloads/big2.txt"
User time (seconds): 23.04
System time (seconds): 0.11
Percent of CPU this job got: 99%
Elapsed (wall clock) time (h:mm:ss or m:ss): 0:23.16
Average shared text size (kbytes): 0
Average unshared data size (kbytes): 0
Average stack size (kbytes): 0
Average total size (kbytes): 0
Maximum resident set size (kbytes): 277928
Average resident set size (kbytes): 0
Major (requiring I/O) page faults: 0
Minor (reclaiming a frame) page faults: 67705
Voluntary context switches: 1
Involuntary context switches: 101
Swaps: 0
File system inputs: 0
File system outputs: 0
Socket messages sent: 0
Socket messages received: 0
Signals delivered: 0
Page size (bytes): 4096
Exit status: 0
Interesting: real/user time on native image identical, on java RC10 not so. Also CPU is 160% on java and on native image nearly 100%.
It does not make sense, that RC-10 java has less real, than user-time, expect there is some concurrency going on.
---
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Paths;
import java.util.Arrays;
import java.util.function.Function;
import java.util.stream.Collectors;
import java.util.stream.Stream;
public class TopTen {
public static void main(String[] args) {
Arrays.stream(args)
.flatMap(TopTen::fileLines)
.flatMap(line -> Arrays.stream(line.split("\\b")))
.map(word -> word.replaceAll("[^a-zA-Z]", ""))
.filter(word -> word.length() > 0)
.map(String::toLowerCase)
.collect(Collectors.groupingBy(Function.identity(), Collectors.counting()))
.entrySet()
.stream()
.sorted((a, b) -> -a.getValue().compareTo(b.getValue()))
.limit(10)
.forEach(e -> System.out.format("%s = %d%n", e.getKey(), e.getValue()));
}
private static Stream<String> fileLines(String path) {
try {
return Files.lines(Paths.get(path));
} catch (IOException e) {
throw new RuntimeException(e);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment