mirror of
https://gitee.com/chinabugotech/hutool.git
synced 2025-05-09 23:51:34 +08:00
fix code
This commit is contained in:
parent
5f45b2275e
commit
867e1ce55e
@ -41,7 +41,6 @@
|
|||||||
<gson.version>2.11.0</gson.version>
|
<gson.version>2.11.0</gson.version>
|
||||||
<fastjson2.version>2.0.41</fastjson2.version>
|
<fastjson2.version>2.0.41</fastjson2.version>
|
||||||
<moshi.version>1.15.1</moshi.version>
|
<moshi.version>1.15.1</moshi.version>
|
||||||
<jmh.version>1.37</jmh.version>
|
|
||||||
</properties>
|
</properties>
|
||||||
|
|
||||||
<dependencies>
|
<dependencies>
|
||||||
@ -108,18 +107,5 @@
|
|||||||
<version>${jjwt.version}</version>
|
<version>${jjwt.version}</version>
|
||||||
<scope>test</scope>
|
<scope>test</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
<!-- 基准性能测试 -->
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.openjdk.jmh</groupId>
|
|
||||||
<artifactId>jmh-core</artifactId>
|
|
||||||
<version>${jmh.version}</version>
|
|
||||||
<scope>test</scope>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.openjdk.jmh</groupId>
|
|
||||||
<artifactId>jmh-generator-annprocess</artifactId>
|
|
||||||
<version>${jmh.version}</version>
|
|
||||||
<scope>test</scope>
|
|
||||||
</dependency>
|
|
||||||
</dependencies>
|
</dependencies>
|
||||||
</project>
|
</project>
|
||||||
|
@ -225,7 +225,9 @@ public interface JSON extends Serializable {
|
|||||||
* @throws JSONException 包含非法数抛出此异常
|
* @throws JSONException 包含非法数抛出此异常
|
||||||
*/
|
*/
|
||||||
default String toJSONString(final int indentFactor) throws JSONException {
|
default String toJSONString(final int indentFactor) throws JSONException {
|
||||||
return toJSONString(indentFactor, null);
|
final JSONWriter jsonWriter = getFactory().ofWriter(new StringBuilder(), indentFactor);
|
||||||
|
this.write(jsonWriter);
|
||||||
|
return jsonWriter.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -38,12 +38,6 @@ public class JsonToStringJmh {
|
|||||||
Assertions.assertNotNull(jsonStr);
|
Assertions.assertNotNull(jsonStr);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Benchmark
|
|
||||||
public void gsonAppendJmh() {
|
|
||||||
final String jsonStr = gson.toString();
|
|
||||||
Assertions.assertNotNull(jsonStr);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Benchmark
|
@Benchmark
|
||||||
public void hutoolJmh() {
|
public void hutoolJmh() {
|
||||||
final String jsonStr = hutoolJSON.toString();
|
final String jsonStr = hutoolJSON.toString();
|
||||||
|
@ -1,6 +1,9 @@
|
|||||||
package org.dromara.hutool.json.jmh;
|
package org.dromara.hutool.json.jmh;
|
||||||
|
|
||||||
import com.alibaba.fastjson2.JSON;
|
import com.alibaba.fastjson2.JSON;
|
||||||
|
import com.fasterxml.jackson.core.JsonProcessingException;
|
||||||
|
import com.fasterxml.jackson.databind.JsonNode;
|
||||||
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||||
import com.google.gson.JsonElement;
|
import com.google.gson.JsonElement;
|
||||||
import com.google.gson.JsonParser;
|
import com.google.gson.JsonParser;
|
||||||
import org.dromara.hutool.json.JSONObject;
|
import org.dromara.hutool.json.JSONObject;
|
||||||
@ -49,4 +52,11 @@ public class ParseTreeJmh {
|
|||||||
final com.alibaba.fastjson2.JSONObject jsonObject = JSON.parseObject(jsonStr);
|
final com.alibaba.fastjson2.JSONObject jsonObject = JSON.parseObject(jsonStr);
|
||||||
assertNotNull(jsonObject);
|
assertNotNull(jsonObject);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Benchmark
|
||||||
|
public void jacksonJmh() throws JsonProcessingException {
|
||||||
|
final ObjectMapper mapper = new ObjectMapper();
|
||||||
|
final JsonNode jsonNode = mapper.readTree(jsonStr);
|
||||||
|
assertNotNull(jsonNode);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
14
pom.xml
14
pom.xml
@ -58,6 +58,7 @@
|
|||||||
<junit.version>5.10.3</junit.version>
|
<junit.version>5.10.3</junit.version>
|
||||||
<lombok.version>1.18.34</lombok.version>
|
<lombok.version>1.18.34</lombok.version>
|
||||||
<kotlin-version>1.9.25</kotlin-version>
|
<kotlin-version>1.9.25</kotlin-version>
|
||||||
|
<jmh.version>1.37</jmh.version>
|
||||||
</properties>
|
</properties>
|
||||||
|
|
||||||
<dependencies>
|
<dependencies>
|
||||||
@ -81,6 +82,19 @@
|
|||||||
<version>${lombok.version}</version>
|
<version>${lombok.version}</version>
|
||||||
<scope>test</scope>
|
<scope>test</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
<!-- 基准性能测试 -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.openjdk.jmh</groupId>
|
||||||
|
<artifactId>jmh-core</artifactId>
|
||||||
|
<version>${jmh.version}</version>
|
||||||
|
<scope>test</scope>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.openjdk.jmh</groupId>
|
||||||
|
<artifactId>jmh-generator-annprocess</artifactId>
|
||||||
|
<version>${jmh.version}</version>
|
||||||
|
<scope>test</scope>
|
||||||
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
||||||
<issueManagement>
|
<issueManagement>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user