Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

upgrade fastjson to 2.0.51 #104

Merged
merged 4 commits into from
Jun 11, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ The results here-below were computed on January the 30th, 2024 with the followin
| avaje-jsonb | 1.9 |
| boon | 0.34 |
| dsl-json | 1.10.0 |
| fastjson | 2.0.46 |
| fastjson | 2.0.51 |
wenshao marked this conversation as resolved.
Show resolved Hide resolved
| flexjson | 3.3 |
| genson | 1.6 |
| gson | 2.10.1 |
Expand Down
4 changes: 2 additions & 2 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,8 @@ dependencies {
implementation group: 'com.dslplatform', name: 'dsl-json', version: "${dslJsonVersion}"
annotationProcessor group: 'com.dslplatform', name: 'dsl-json', version: "${dslJsonVersion}"
// FastJson
implementation group: 'com.alibaba.fastjson2', name: 'fastjson2', version: '2.0.48'
implementation group: 'com.alibaba.fastjson2', name: 'fastjson2-incubator-vector', version: '2.0.48'
implementation group: 'com.alibaba.fastjson2', name: 'fastjson2', version: '2.0.51'
implementation group: 'com.alibaba.fastjson2', name: 'fastjson2-incubator-vector', version: '2.0.51'
// FlexJson
implementation group: 'net.sf.flexjson', name: 'flexjson', version: '3.3'
// GENSON
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 @@ -51,6 +51,10 @@ public Object fastjson() throws Exception {
return null;
}

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

public Object jsonio() throws Exception {
return null;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package com.github.fabienrenaud.jjb.databind;

import com.alibaba.fastjson2.JSON;
import com.alibaba.fastjson2.JSONReader;
import com.alibaba.fastjson2.reader.ObjectReaderProvider;
import com.bluelinelabs.logansquare.LoganSquare;
import com.github.fabienrenaud.jjb.JsonBench;
import com.github.fabienrenaud.jjb.data.JsonSource;
Expand All @@ -15,6 +17,16 @@
* @author Fabien Renaud
*/
public class Deserialization extends JsonBench {
static final ObjectReaderProvider featuresProvider = new ObjectReaderProvider();
static final JSONReader.Context featuresContext;
static {
featuresProvider.setDisableArrayMapping(true);
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I cannot find such methods when searching on github / fastjson2. Can you provide a link to show me where these are published/pushed?

featuresProvider.setDisableAutoType(true);
featuresProvider.setDisableJSONB(true);
featuresProvider.setDisableReferenceDetect(true);
featuresProvider.setDisableSmartMatch(true);
featuresContext = new JSONReader.Context(featuresProvider);
}
wenshao marked this conversation as resolved.
Show resolved Hide resolved

public JsonSource JSON_SOURCE() {
return CLI_JSON_SOURCE;
Expand Down Expand Up @@ -62,6 +74,12 @@ public Object fastjson() {
return JSON.parseObject(JSON_SOURCE().nextByteArray(), JSON_SOURCE().pojoType());
}

@Benchmark
@Override
public Object fastjson_features() {
return JSON.parseObject(JSON_SOURCE().nextByteArray(), JSON_SOURCE().pojoType(), featuresContext);
}

@Benchmark
@Override
public Object flexjson() throws JsonSyntaxException {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
package com.github.fabienrenaud.jjb.databind;

import com.alibaba.fastjson2.JSON;
import com.alibaba.fastjson2.JSONFactory;
import com.alibaba.fastjson2.JSONWriter;
import com.alibaba.fastjson2.writer.ObjectWriterProvider;
import com.bluelinelabs.logansquare.LoganSquare;
import com.github.fabienrenaud.jjb.JsonBench;
import com.github.fabienrenaud.jjb.JsonUtils;
Expand All @@ -13,6 +16,15 @@
import java.io.ByteArrayOutputStream;

public class Serialization extends JsonBench {
static final ObjectWriterProvider featuresProvider = new ObjectWriterProvider();
static final JSONWriter.Context featuresContext;
static {
featuresProvider.setDisableAutoType(true);
featuresProvider.setDisableArrayMapping(true);
featuresProvider.setDisableJSONB(true);
featuresProvider.setDisableReferenceDetect(true);
featuresContext = JSONFactory.createWriteContext(featuresProvider);
}

public JsonSource JSON_SOURCE() {
return CLI_JSON_SOURCE;
Expand Down Expand Up @@ -74,6 +86,14 @@ public Object fastjson() throws Exception {
return baos;
}

@Benchmark
@Override
public Object fastjson_features() throws Exception {
ByteArrayOutputStream baos = JsonUtils.byteArrayOutputStream();
JSON.writeTo(baos, JSON_SOURCE().nextPojo(), featuresContext);
return baos;
}

@Benchmark
@Override
public Object flexjson() {
Expand Down
Loading