From 993e6cb891583bcb91977622ca4fc72fbe6ce633 Mon Sep 17 00:00:00 2001 From: wangyc Date: Thu, 4 Apr 2024 19:38:34 +0800 Subject: [PATCH 1/8] Add the WAST library for testing --- build.gradle | 1 + src/main/java/com/github/fabienrenaud/jjb/JsonBench.java | 4 ++++ .../github/fabienrenaud/jjb/databind/Deserialization.java | 5 +++++ .../github/fabienrenaud/jjb/databind/Serialization.java | 7 +++++++ .../java/com/github/fabienrenaud/jjb/model/Clients.java | 4 ++++ src/main/java/com/github/fabienrenaud/jjb/model/Users.java | 4 ++++ .../com/github/fabienrenaud/jjb/support/BenchSupport.java | 4 +++- .../java/com/github/fabienrenaud/jjb/support/Library.java | 4 +++- .../java/com/github/fabienrenaud/jjb/JsonBenchmark.java | 7 +++++++ 9 files changed, 38 insertions(+), 2 deletions(-) diff --git a/build.gradle b/build.gradle index f5fbaee..e619bef 100644 --- a/build.gradle +++ b/build.gradle @@ -98,6 +98,7 @@ dependencies { implementation group: 'org.eclipse', name: 'yasson', version: '3.0.3' // QuickBuffers implementation group: 'us.hebi.quickbuf', name: 'quickbuf-runtime', version: '1.4' + implementation group: 'io.github.wycst', name: 'wast', version: '0.0.12.1' // Test testImplementation group: 'junit', name: 'junit', version: '4.13.2' diff --git a/src/main/java/com/github/fabienrenaud/jjb/JsonBench.java b/src/main/java/com/github/fabienrenaud/jjb/JsonBench.java index 26a65c0..f17e137 100644 --- a/src/main/java/com/github/fabienrenaud/jjb/JsonBench.java +++ b/src/main/java/com/github/fabienrenaud/jjb/JsonBench.java @@ -135,4 +135,8 @@ public Object quickbuf_json() throws Exception { return null; } + public Object wast() throws Exception { + return null; + } + } diff --git a/src/main/java/com/github/fabienrenaud/jjb/databind/Deserialization.java b/src/main/java/com/github/fabienrenaud/jjb/databind/Deserialization.java index 78f0abc..2d6612d 100644 --- a/src/main/java/com/github/fabienrenaud/jjb/databind/Deserialization.java +++ b/src/main/java/com/github/fabienrenaud/jjb/databind/Deserialization.java @@ -144,4 +144,9 @@ public Object quickbuf_json() throws Exception { .mergeFrom(us.hebi.quickbuf.JsonSource.newInstance(JSON_SOURCE().nextByteArray())); } + @Benchmark + @Override + public Object wast() throws Exception { + return io.github.wycst.wast.json.JSON.parseObject(JSON_SOURCE().nextString(), JSON_SOURCE().pojoType()); + } } diff --git a/src/main/java/com/github/fabienrenaud/jjb/databind/Serialization.java b/src/main/java/com/github/fabienrenaud/jjb/databind/Serialization.java index f750014..9f82267 100644 --- a/src/main/java/com/github/fabienrenaud/jjb/databind/Serialization.java +++ b/src/main/java/com/github/fabienrenaud/jjb/databind/Serialization.java @@ -175,4 +175,11 @@ public Object quickbuf_json() throws Exception { return JSON_SOURCE().provider().quickbufSink().clear().writeMessage(JSON_SOURCE().nextQuickbufPojo()); } + @Benchmark + @Override + public Object wast() throws Exception { + ByteArrayOutputStream baos = JsonUtils.byteArrayOutputStream(); + io.github.wycst.wast.json.JSON.writeJsonTo(JSON_SOURCE().nextPojo(), baos); + return baos; + } } diff --git a/src/main/java/com/github/fabienrenaud/jjb/model/Clients.java b/src/main/java/com/github/fabienrenaud/jjb/model/Clients.java index aef1cfe..26d9a32 100644 --- a/src/main/java/com/github/fabienrenaud/jjb/model/Clients.java +++ b/src/main/java/com/github/fabienrenaud/jjb/model/Clients.java @@ -5,6 +5,7 @@ import com.bluelinelabs.logansquare.typeconverters.StringBasedTypeConverter; import com.dslplatform.json.CompiledJson; import com.dslplatform.json.JsonAttribute; +import io.github.wycst.wast.json.annotations.JsonTypeSetting; import java.math.BigDecimal; import java.time.LocalDate; @@ -18,6 +19,7 @@ @JsonObject @CompiledJson @jodd.json.meta.JSON +@JsonTypeSetting(enableJIT = true) public class Clients { @JsonField @@ -58,6 +60,7 @@ public void setClients(List clients) { @io.avaje.jsonb.Json @JsonObject + @JsonTypeSetting(enableJIT = true) public static final class Client { @JsonField @@ -395,6 +398,7 @@ public static EyeColor fromNumber(int i) { @io.avaje.jsonb.Json @JsonObject + @JsonTypeSetting(enableJIT = true) public static final class Partner { @JsonField diff --git a/src/main/java/com/github/fabienrenaud/jjb/model/Users.java b/src/main/java/com/github/fabienrenaud/jjb/model/Users.java index dd221a2..39acdc1 100644 --- a/src/main/java/com/github/fabienrenaud/jjb/model/Users.java +++ b/src/main/java/com/github/fabienrenaud/jjb/model/Users.java @@ -4,6 +4,7 @@ import com.bluelinelabs.logansquare.annotation.JsonObject; import com.dslplatform.json.CompiledJson; import com.dslplatform.json.JsonAttribute; +import io.github.wycst.wast.json.annotations.JsonTypeSetting; import java.util.List; import java.util.Objects; @@ -12,6 +13,7 @@ @JsonObject @CompiledJson @jodd.json.meta.JSON +@JsonTypeSetting(enableJIT = true) public class Users { @JsonField @@ -53,6 +55,7 @@ public void setUsers(List users) { @io.avaje.jsonb.Json @JsonObject @CompiledJson + @JsonTypeSetting(enableJIT = true) public static final class User { @JsonField @@ -329,6 +332,7 @@ public void setFavoriteFruit(String favoriteFruit) { @io.avaje.jsonb.Json @JsonObject @CompiledJson + @JsonTypeSetting(enableJIT = true) public static final class Friend { @JsonField diff --git a/src/main/java/com/github/fabienrenaud/jjb/support/BenchSupport.java b/src/main/java/com/github/fabienrenaud/jjb/support/BenchSupport.java index 90ae27d..d85d75b 100644 --- a/src/main/java/com/github/fabienrenaud/jjb/support/BenchSupport.java +++ b/src/main/java/com/github/fabienrenaud/jjb/support/BenchSupport.java @@ -37,7 +37,8 @@ public enum BenchSupport { new Libapi(Library.QSON, Api.DATABIND), new Libapi(Library.PUREJSON, Api.STREAM), new Libapi(Library.ANTONS, Api.STREAM), - new Libapi(Library.QUICKBUF_JSON, Api.DATABIND) + new Libapi(Library.QUICKBUF_JSON, Api.DATABIND), + new Libapi(Library.WAST, Api.DATABIND) ), CLIENTS( new Libapi(Library.GSON, Api.DATABIND), @@ -63,6 +64,7 @@ public enum BenchSupport { new Libapi(Library.NANOJSON), new Libapi(Library.JODD, Api.DATABIND), new Libapi(Library.MOSHI, Api.DATABIND), + new Libapi(Library.WAST, Api.DATABIND), new Libapi(Library.TAPESTRY), new Libapi(Library.MINIMALJSON), new Libapi(Library.UNDERSCORE_JAVA), diff --git a/src/main/java/com/github/fabienrenaud/jjb/support/Library.java b/src/main/java/com/github/fabienrenaud/jjb/support/Library.java index 29405f4..ca6e1a2 100644 --- a/src/main/java/com/github/fabienrenaud/jjb/support/Library.java +++ b/src/main/java/com/github/fabienrenaud/jjb/support/Library.java @@ -35,7 +35,9 @@ public enum Library { UNDERSCORE_JAVA, PUREJSON, ANTONS, - QUICKBUF_JSON; + QUICKBUF_JSON, + WAST + ; public static Set fromCsv(String str) { if (str == null || str.trim().isEmpty()) { diff --git a/src/test/java/com/github/fabienrenaud/jjb/JsonBenchmark.java b/src/test/java/com/github/fabienrenaud/jjb/JsonBenchmark.java index 2aecd82..05c9679 100644 --- a/src/test/java/com/github/fabienrenaud/jjb/JsonBenchmark.java +++ b/src/test/java/com/github/fabienrenaud/jjb/JsonBenchmark.java @@ -279,4 +279,11 @@ public void quickbuf_json() throws Exception { } } + @Test + public void wast_json() throws Exception { + for (int i = 0; i < ITERATIONS; i++) { + test(Library.WAST, BENCH.wast()); + } + } + } From b0335f0ce772511e5493a36c93e904815c6ceda0 Mon Sep 17 00:00:00 2001 From: wangyc Date: Thu, 4 Apr 2024 20:10:31 +0800 Subject: [PATCH 2/8] Add the WAST library for testing --- build.gradle | 1 + 1 file changed, 1 insertion(+) diff --git a/build.gradle b/build.gradle index e619bef..246c5db 100644 --- a/build.gradle +++ b/build.gradle @@ -98,6 +98,7 @@ dependencies { implementation group: 'org.eclipse', name: 'yasson', version: '3.0.3' // QuickBuffers implementation group: 'us.hebi.quickbuf', name: 'quickbuf-runtime', version: '1.4' + // wast implementation group: 'io.github.wycst', name: 'wast', version: '0.0.12.1' // Test From 7dccdf07992a8395a29e65b446338c9112befb80 Mon Sep 17 00:00:00 2001 From: wangyc Date: Wed, 17 Apr 2024 18:08:46 +0800 Subject: [PATCH 3/8] Move semi-colon to the same line as WAST. --- src/main/java/com/github/fabienrenaud/jjb/support/Library.java | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/main/java/com/github/fabienrenaud/jjb/support/Library.java b/src/main/java/com/github/fabienrenaud/jjb/support/Library.java index ca6e1a2..7f61f57 100644 --- a/src/main/java/com/github/fabienrenaud/jjb/support/Library.java +++ b/src/main/java/com/github/fabienrenaud/jjb/support/Library.java @@ -36,8 +36,7 @@ public enum Library { PUREJSON, ANTONS, QUICKBUF_JSON, - WAST - ; + WAST; public static Set fromCsv(String str) { if (str == null || str.trim().isEmpty()) { From 203b686c0352c400aab22c21b0575a751b989dcb Mon Sep 17 00:00:00 2001 From: wangyc Date: Thu, 18 Apr 2024 22:51:53 +0800 Subject: [PATCH 4/8] new lib name and version --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index c18a72f..9a7c9af 100644 --- a/README.md +++ b/README.md @@ -82,6 +82,7 @@ The results here-below were computed on January the 30th, 2024 with the followin | tapestry | 5.8.3 | | underscore | 1.97 | | yasson | 3.0.3 | +| wast | 0.0.12.1 | [All graphs and sheets are available in this google doc.][spreadsheet] From 9a127b6dce844b072b8ee931a10e227b2a2095cf Mon Sep 17 00:00:00 2001 From: wangyc Date: Sat, 4 May 2024 11:28:58 +0800 Subject: [PATCH 5/8] Use the built-in Double API of JDK to read and write double precision --- .../com/github/fabienrenaud/jjb/databind/Deserialization.java | 3 ++- .../com/github/fabienrenaud/jjb/databind/Serialization.java | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/github/fabienrenaud/jjb/databind/Deserialization.java b/src/main/java/com/github/fabienrenaud/jjb/databind/Deserialization.java index 2d6612d..6e93923 100644 --- a/src/main/java/com/github/fabienrenaud/jjb/databind/Deserialization.java +++ b/src/main/java/com/github/fabienrenaud/jjb/databind/Deserialization.java @@ -5,6 +5,7 @@ import com.github.fabienrenaud.jjb.JsonBench; import com.github.fabienrenaud.jjb.data.JsonSource; import com.google.gson.JsonSyntaxException; +import io.github.wycst.wast.json.options.ReadOption; import org.openjdk.jmh.annotations.Benchmark; import java.io.IOException; @@ -147,6 +148,6 @@ public Object quickbuf_json() throws Exception { @Benchmark @Override public Object wast() throws Exception { - return io.github.wycst.wast.json.JSON.parseObject(JSON_SOURCE().nextString(), JSON_SOURCE().pojoType()); + return io.github.wycst.wast.json.JSON.parseObject(JSON_SOURCE().nextString(), JSON_SOURCE().pojoType(), ReadOption.UseJDKDoubleParser); } } diff --git a/src/main/java/com/github/fabienrenaud/jjb/databind/Serialization.java b/src/main/java/com/github/fabienrenaud/jjb/databind/Serialization.java index 9f82267..03ea550 100644 --- a/src/main/java/com/github/fabienrenaud/jjb/databind/Serialization.java +++ b/src/main/java/com/github/fabienrenaud/jjb/databind/Serialization.java @@ -5,6 +5,7 @@ import com.github.fabienrenaud.jjb.JsonBench; import com.github.fabienrenaud.jjb.JsonUtils; import com.github.fabienrenaud.jjb.data.JsonSource; +import io.github.wycst.wast.json.options.WriteOption; import okio.BufferedSink; import okio.Okio; import org.openjdk.jmh.annotations.Benchmark; @@ -179,7 +180,7 @@ public Object quickbuf_json() throws Exception { @Override public Object wast() throws Exception { ByteArrayOutputStream baos = JsonUtils.byteArrayOutputStream(); - io.github.wycst.wast.json.JSON.writeJsonTo(JSON_SOURCE().nextPojo(), baos); + io.github.wycst.wast.json.JSON.writeJsonTo(JSON_SOURCE().nextPojo(), baos, WriteOption.WriteDecimalUseToString); return baos; } } From 73cc6bdb2b124644bd4402db0997d08bb97dd01f Mon Sep 17 00:00:00 2001 From: wangyc Date: Sat, 4 May 2024 11:43:23 +0800 Subject: [PATCH 6/8] update README.md add wast link --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index 9a7c9af..4847f26 100644 --- a/README.md +++ b/README.md @@ -31,6 +31,7 @@ It covers the following libraries: * [qson](https://github.com/quarkusio/qson) * [tapestry](https://tapestry.apache.org/json.html) * [underscore-java](https://github.com/javadev/underscore-java) +* [wast](https://github.com/wycst) When available, both databinding and 'stream' (custom packing and unpacking) implementations are tested. Two different kinds of [models](/src/main/java/com/github/fabienrenaud/jjb/model/) are evaluated with payloads of 1, 10, From 3c4ecf7d42705075670ded9c8339f7429abc3649 Mon Sep 17 00:00:00 2001 From: wangyc Date: Sun, 30 Jun 2024 09:33:59 +0800 Subject: [PATCH 7/8] Updated the WAST version to optimize the read and write performance of floating-point numbers --- README.md | 2 +- build.gradle | 2 +- .../com/github/fabienrenaud/jjb/databind/Deserialization.java | 2 +- .../com/github/fabienrenaud/jjb/databind/Serialization.java | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 55b24f5..153b36e 100644 --- a/README.md +++ b/README.md @@ -83,7 +83,7 @@ The results here-below were computed on January the 30th, 2024 with the followin | tapestry | 5.8.3 | | underscore | 1.97 | | yasson | 3.0.3 | -| wast | 0.0.12.1 | +| wast | 0.0.13.2 | [All graphs and sheets are available in this google doc.][spreadsheet] diff --git a/build.gradle b/build.gradle index 8ba6bd6..f6992e9 100644 --- a/build.gradle +++ b/build.gradle @@ -99,7 +99,7 @@ dependencies { // QuickBuffers implementation group: 'us.hebi.quickbuf', name: 'quickbuf-runtime', version: '1.4' // wast - implementation group: 'io.github.wycst', name: 'wast', version: '0.0.12.1' + implementation group: 'io.github.wycst', name: 'wast', version: '0.0.13.2' // Test testImplementation group: 'junit', name: 'junit', version: '4.13.2' diff --git a/src/main/java/com/github/fabienrenaud/jjb/databind/Deserialization.java b/src/main/java/com/github/fabienrenaud/jjb/databind/Deserialization.java index 72511e3..114b8f7 100644 --- a/src/main/java/com/github/fabienrenaud/jjb/databind/Deserialization.java +++ b/src/main/java/com/github/fabienrenaud/jjb/databind/Deserialization.java @@ -153,6 +153,6 @@ public Object quickbuf_json() throws Exception { @Benchmark @Override public Object wast() throws Exception { - return io.github.wycst.wast.json.JSON.parseObject(JSON_SOURCE().nextString(), JSON_SOURCE().pojoType(), ReadOption.UseJDKDoubleParser); + return io.github.wycst.wast.json.JSON.parseObject(JSON_SOURCE().nextString(), JSON_SOURCE().pojoType()/*, ReadOption.UseJDKDoubleParser*/); } } diff --git a/src/main/java/com/github/fabienrenaud/jjb/databind/Serialization.java b/src/main/java/com/github/fabienrenaud/jjb/databind/Serialization.java index b31296b..65a1e68 100644 --- a/src/main/java/com/github/fabienrenaud/jjb/databind/Serialization.java +++ b/src/main/java/com/github/fabienrenaud/jjb/databind/Serialization.java @@ -187,7 +187,7 @@ public Object quickbuf_json() throws Exception { @Override public Object wast() throws Exception { ByteArrayOutputStream baos = JsonUtils.byteArrayOutputStream(); - io.github.wycst.wast.json.JSON.writeJsonTo(JSON_SOURCE().nextPojo(), baos, WriteOption.WriteDecimalUseToString); + io.github.wycst.wast.json.JSON.writeJsonTo(JSON_SOURCE().nextPojo(), baos/*, WriteOption.WriteDecimalUseToString*/); return baos; } } From a6d0e40e8c5daef1de8cd027516597c1cd9fc8a4 Mon Sep 17 00:00:00 2001 From: wangyc Date: Tue, 2 Jul 2024 12:09:09 +0800 Subject: [PATCH 8/8] Clear useless comments --- .../com/github/fabienrenaud/jjb/databind/Deserialization.java | 2 +- .../com/github/fabienrenaud/jjb/databind/Serialization.java | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/github/fabienrenaud/jjb/databind/Deserialization.java b/src/main/java/com/github/fabienrenaud/jjb/databind/Deserialization.java index 114b8f7..c8567e9 100644 --- a/src/main/java/com/github/fabienrenaud/jjb/databind/Deserialization.java +++ b/src/main/java/com/github/fabienrenaud/jjb/databind/Deserialization.java @@ -153,6 +153,6 @@ public Object quickbuf_json() throws Exception { @Benchmark @Override public Object wast() throws Exception { - return io.github.wycst.wast.json.JSON.parseObject(JSON_SOURCE().nextString(), JSON_SOURCE().pojoType()/*, ReadOption.UseJDKDoubleParser*/); + return io.github.wycst.wast.json.JSON.parseObject(JSON_SOURCE().nextString(), JSON_SOURCE().pojoType()); } } diff --git a/src/main/java/com/github/fabienrenaud/jjb/databind/Serialization.java b/src/main/java/com/github/fabienrenaud/jjb/databind/Serialization.java index 65a1e68..89738b4 100644 --- a/src/main/java/com/github/fabienrenaud/jjb/databind/Serialization.java +++ b/src/main/java/com/github/fabienrenaud/jjb/databind/Serialization.java @@ -187,7 +187,7 @@ public Object quickbuf_json() throws Exception { @Override public Object wast() throws Exception { ByteArrayOutputStream baos = JsonUtils.byteArrayOutputStream(); - io.github.wycst.wast.json.JSON.writeJsonTo(JSON_SOURCE().nextPojo(), baos/*, WriteOption.WriteDecimalUseToString*/); + io.github.wycst.wast.json.JSON.writeJsonTo(JSON_SOURCE().nextPojo(), baos); return baos; } }