Skip to content

Commit

Permalink
Add the WAST library (#102)
Browse files Browse the repository at this point in the history
  • Loading branch information
wycst authored Apr 18, 2024
1 parent ed3ba73 commit 414e760
Show file tree
Hide file tree
Showing 10 changed files with 39 additions and 2 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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]

Expand Down
2 changes: 2 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,8 @@ 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
testImplementation group: 'junit', name: 'junit', version: '4.13.2'
Expand Down
4 changes: 4 additions & 0 deletions src/main/java/com/github/fabienrenaud/jjb/JsonBench.java
Original file line number Diff line number Diff line change
Expand Up @@ -135,4 +135,8 @@ public Object quickbuf_json() throws Exception {
return null;
}

public Object wast() throws Exception {
return null;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -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());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}
4 changes: 4 additions & 0 deletions src/main/java/com/github/fabienrenaud/jjb/model/Clients.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -18,6 +19,7 @@
@JsonObject
@CompiledJson
@jodd.json.meta.JSON
@JsonTypeSetting(enableJIT = true)
public class Clients {

@JsonField
Expand Down Expand Up @@ -58,6 +60,7 @@ public void setClients(List<Client> clients) {

@io.avaje.jsonb.Json
@JsonObject
@JsonTypeSetting(enableJIT = true)
public static final class Client {

@JsonField
Expand Down Expand Up @@ -395,6 +398,7 @@ public static EyeColor fromNumber(int i) {

@io.avaje.jsonb.Json
@JsonObject
@JsonTypeSetting(enableJIT = true)
public static final class Partner {

@JsonField
Expand Down
4 changes: 4 additions & 0 deletions src/main/java/com/github/fabienrenaud/jjb/model/Users.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -12,6 +13,7 @@
@JsonObject
@CompiledJson
@jodd.json.meta.JSON
@JsonTypeSetting(enableJIT = true)
public class Users {

@JsonField
Expand Down Expand Up @@ -53,6 +55,7 @@ public void setUsers(List<User> users) {
@io.avaje.jsonb.Json
@JsonObject
@CompiledJson
@JsonTypeSetting(enableJIT = true)
public static final class User {

@JsonField
Expand Down Expand Up @@ -329,6 +332,7 @@ public void setFavoriteFruit(String favoriteFruit) {
@io.avaje.jsonb.Json
@JsonObject
@CompiledJson
@JsonTypeSetting(enableJIT = true)
public static final class Friend {

@JsonField
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand All @@ -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),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,8 @@ public enum Library {
UNDERSCORE_JAVA,
PUREJSON,
ANTONS,
QUICKBUF_JSON;
QUICKBUF_JSON,
WAST;

public static Set<Library> fromCsv(String str) {
if (str == null || str.trim().isEmpty()) {
Expand Down
7 changes: 7 additions & 0 deletions src/test/java/com/github/fabienrenaud/jjb/JsonBenchmark.java
Original file line number Diff line number Diff line change
Expand Up @@ -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());
}
}

}

0 comments on commit 414e760

Please sign in to comment.