@@ -10,6 +10,8 @@ by Geoff Langdale and Daniel Lemire.
10
10
11
11
## Code Sample
12
12
13
+ ### DOM Parser
14
+
13
15
``` java
14
16
byte [] json = loadTwitterJson();
15
17
@@ -25,6 +27,30 @@ while (tweets.hasNext()) {
25
27
}
26
28
```
27
29
30
+ ### Schema-Based Parser
31
+
32
+ ``` java
33
+ byte [] json = loadTwitterJson();
34
+
35
+ SimdJsonParser parser = new SimdJsonParser ();
36
+ SimdJsonTwitter twitter = simdJsonParser. parse(buffer, buffer. length, SimdJsonTwitter . class);
37
+ for (SimdJsonStatus status : twitter. statuses()) {
38
+ SimdJsonUser user = status. user();
39
+ if (user. default_profile()) {
40
+ System . out. println(user. screen_name());
41
+ }
42
+ }
43
+
44
+ record SimdJsonUser(boolean default_profile, String screen_name) {
45
+ }
46
+
47
+ record SimdJsonStatus(SimdJsonUser user) {
48
+ }
49
+
50
+ record SimdJsonTwitter(List<SimdJsonStatus > statuses) {
51
+ }
52
+ ```
53
+
28
54
## Installation
29
55
30
56
The library is available in the [ Maven Central Repository] ( https://mvnrepository.com/artifact/org.simdjson/simdjson-java ) .
@@ -67,24 +93,60 @@ This section presents a performance comparison of different JSON parsers availab
67
93
the [ twitter.json] ( src/jmh/resources/twitter.json ) dataset, and its goal was to measure the throughput (ops/s) of parsing
68
94
and finding all unique users with a default profile.
69
95
70
- ** Note that simdjson-java is still missing several features (see [ GitHub Issues] ( https://github.com/simdjson/simdjson-java/issues ) ),
71
- so the following results may not reflect its real performance.**
96
+ ### 256-bit Vectors
72
97
73
98
Environment:
74
- * CPU: Intel(R) Core(TM) i5-4590 CPU @ 3.30GHz
75
- * OS: Ubuntu 23.04, kernel 6.2.0-23-generic
76
- * Java: OpenJDK 64-Bit Server VM Temurin-20.0.1+9
77
-
78
- Library | Version | Throughput (ops/s)
79
- ---------------------------------------------------|---------|--------------------
80
- simdjson-java | - | 1450.951
81
- simdjson-java (padded) | - | 1505.227
82
- [ jackson] ( https://github.com/FasterXML/jackson ) | 2.15.2 | 504.562
83
- [ fastjson2] ( https://github.com/alibaba/fastjson ) | 2.0.35 | 590.743
84
- [ jsoniter] ( https://github.com/json-iterator/java ) | 0.9.23 | 384.664
99
+ * CPU: Intel(R) Xeon(R) CPU E5-2686 v4 @ 2.30GHz
100
+ * OS: Ubuntu 24.04 LTS, kernel 6.8.0-1008-aws
101
+ * Java: OpenJDK 64-Bit Server VM (build 21.0.3+9-Ubuntu-1ubuntu1, mixed mode, sharing)
102
+
103
+ DOM parsers ([ ParseAndSelectBenchmark] ( src/jmh/java/org/simdjson/ParseAndSelectBenchmark.java ) ):
104
+
105
+ | Library | Version | Throughput (ops/s) |
106
+ | --------------------------------------------------| ---------| --------------------|
107
+ | simdjson-java (padded) | 0.3.0 | 783.878 |
108
+ | simdjson-java | 0.3.0 | 760.426 |
109
+ | [ fastjson2] ( https://github.com/alibaba/fastjson ) | 2.0.49 | 308.660 |
110
+ | [ jackson] ( https://github.com/FasterXML/jackson ) | 2.17.0 | 259.536 |
111
+
112
+ Schema-based parsers ([ SchemaBasedParseAndSelectBenchmark] ( src/jmh/java/org/simdjson/SchemaBasedParseAndSelectBenchmark.java ) ):
113
+
114
+ | Library | Version | Throughput (ops/s) |
115
+ | -----------------------------------------------------------------| ---------| --------------------|
116
+ | simdjson-java (padded) | 0.3.0 | 1237.432 |
117
+ | simdjson-java | 0.3.0 | 1216.891 |
118
+ | [ jsoniter-scala] ( https://github.com/plokhotnyuk/jsoniter-scala ) | 2.28.4 | 614.138 |
119
+ | [ fastjson2] ( https://github.com/alibaba/fastjson ) | 2.0.49 | 494.362 |
120
+ | [ jackson] ( https://github.com/FasterXML/jackson ) | 2.17.0 | 339.904 |
121
+
122
+ ### 512-bit Vectors
123
+
124
+ Environment:
125
+ * CPU: Intel(R) Xeon(R) Platinum 8375C CPU @ 2.90GHz
126
+ * OS: Ubuntu 24.04 LTS, kernel 6.8.0-1008-aws
127
+ * Java: OpenJDK 64-Bit Server VM (build 21.0.3+9-Ubuntu-1ubuntu1, mixed mode, sharing)
128
+
129
+ DOM parsers ([ ParseAndSelectBenchmark] ( src/jmh/java/org/simdjson/ParseAndSelectBenchmark.java ) ):
130
+
131
+ | Library | Version | Throughput (ops/s) |
132
+ | --------------------------------------------------| ---------| --------------------|
133
+ | simdjson-java (padded) | 0.3.0 | 1842.146 |
134
+ | simdjson-java | 0.3.0 | 1765.592 |
135
+ | [ fastjson2] ( https://github.com/alibaba/fastjson ) | 2.0.49 | 718.133 |
136
+ | [ jackson] ( https://github.com/FasterXML/jackson ) | 2.17.0 | 616.617 |
137
+
138
+ Schema-based parsers ([ SchemaBasedParseAndSelectBenchmark] ( src/jmh/java/org/simdjson/SchemaBasedParseAndSelectBenchmark.java ) ):
139
+
140
+ | Library | Version | Throughput (ops/s) |
141
+ | -----------------------------------------------------------------| ---------| --------------------|
142
+ | simdjson-java (padded) | 0.3.0 | 3164.274 |
143
+ | simdjson-java | 0.3.0 | 2990.289 |
144
+ | [ jsoniter-scala] ( https://github.com/plokhotnyuk/jsoniter-scala ) | 2.28.4 | 1826.229 |
145
+ | [ fastjson2] ( https://github.com/alibaba/fastjson ) | 2.0.49 | 1259.622 |
146
+ | [ jackson] ( https://github.com/FasterXML/jackson ) | 2.17.0 | 789.030 |
85
147
86
148
To reproduce the benchmark results, execute the following command:
87
149
88
150
``` ./gradlew jmh -Pjmh.includes='.*ParseAndSelectBenchmark.*' ```
89
151
90
- The benchmark may take several minutes. Remember that you need Java 18 or better.
152
+ The benchmark may take several minutes. Remember that you need Java 18 or better.
0 commit comments