# wast-jmh-test
**Repository Path**: xiaoch0209/wast-jmh-test
## Basic Information
- **Project Name**: wast-jmh-test
- **Description**: wast性能测试
- **Primary Language**: Java
- **License**: Not specified
- **Default Branch**: main
- **Homepage**: None
- **GVP Project**: No
## Statistics
- **Stars**: 1
- **Forks**: 0
- **Created**: 2022-12-13
- **Last Updated**: 2025-03-07
## Categories & Tags
**Categories**: Uncategorized
**Tags**: None
## README
# wast-jmh-test
github源码地址:
[https://github.com/wycst/wast](https://github.com/wycst/wast)
藏了2年的一个java库,已发布到了maven中央仓库,由于groupId的限制,重构了所有的包名。
从工具库到web框架,有条件会陆续放出来。
```xml
io.github.wycst
wast
0.0.3
```
以下针对部分模块做的性能评测数据(性能测试结果仅限选择场景样本和测试服务器)
测试环境
- 服务器: window10 32g i5 ssd
- ide: idea2020.3
版本信息
- jdk: 1.8.0_45
- jmh.v1.3.5
- **wast.v0.0.3**
- fastjson.v1.2.83
- fastjson2.v2.0.6
- jackson.v.2.9.9.3
- spel.v5.3.9
- snakeyaml.v1.29
~~~
8
8
1.35
5.3.9
1.2.83
2.0.6
1.29
2.9.9.3
io.github.wycst
wast
0.0.3
com.alibaba.fastjson2
fastjson2
${fastjson2.version}
com.alibaba
fastjson
${fastjson1.version}
com.fasterxml.jackson.core
jackson-databind
${jackson.version}
org.springframework
spring-expression
${spring.version}
org.yaml
snakeyaml
${snakeyaml-version}
org.openjdk.jmh
jmh-core
${jmh.version}
org.openjdk.jmh
jmh-generator-annprocess
${jmh.version}
~~~
## JSON篇
- 反序列化 - 简单实体bean的解析(ops/ms)
~~~
Benchmark Mode Cnt Score Error Units
SimpleBeanTest.fastjson1 thrpt 5 295.223 ± 25.515 ops/ms
SimpleBeanTest.fastjson2 thrpt 5 785.447 ± 14.362 ops/ms
SimpleBeanTest.jackson thrpt 5 474.894 ± 26.205 ops/ms
SimpleBeanTest.wastjson thrpt 5 1189.094 ± 60.265 ops/ms
~~~
测试类: https://github.com/wycst/wast-jmh-test/blob/main/src/main/java/com/jmh/test/json/bean/SimpleBeanTest.java
测试结果: wastjson >> fastjson2 > jackson > fastjson1
- 反序列化 - 小文本解析测试(ops/ms)
~~~
Benchmark Mode Cnt Score Error Units
SmallTextParseTest.fastjson1 thrpt 5 1479.282 ± 17.987 ops/ms
SmallTextParseTest.fastjson2 thrpt 5 2401.221 ± 77.762 ops/ms
SmallTextParseTest.jackson thrpt 5 1427.027 ± 54.206 ops/ms
SmallTextParseTest.wastjson thrpt 5 2199.300 ± 30.759 ops/ms
~~~
测试类: https://github.com/wycst/wast-jmh-test/blob/main/src/main/java/com/jmh/test/json/bean/SmallTextParseTest.java
测试结果: fastjson2 > wastjson > fastjson1 > jackson
- 反序列化 - 中长文本测试(175kb)(ops/s)
~~~
Benchmark Mode Cnt Score Error Units
LongTextParseTest.escapeFastjson1 thrpt 5 2403.397 ± 67.258 ops/s
LongTextParseTest.escapeFastjson2 thrpt 5 2470.036 ± 41.012 ops/s
LongTextParseTest.escapeJackson thrpt 5 2264.022 ± 63.137 ops/s
LongTextParseTest.escapeWastjson thrpt 5 9946.527 ± 249.772 ops/s
LongTextParseTest.escapePrettyFastjson thrpt 5 2631.821 ± 40.613 ops/s
LongTextParseTest.escapePrettyFastjson2 thrpt 5 2433.739 ± 40.984 ops/s
LongTextParseTest.escapePrettyJackson thrpt 5 1568.147 ± 103.349 ops/s
LongTextParseTest.escapePrettyWastjson thrpt 5 9961.827 ± 551.414 ops/s
LongTextParseTest.fastjson1 thrpt 5 5118.035 ± 112.711 ops/s
LongTextParseTest.fastjson2 thrpt 5 6850.418 ± 147.904 ops/s
LongTextParseTest.jackson thrpt 5 2936.602 ± 39.819 ops/s
LongTextParseTest.wastjson thrpt 5 9468.415 ± 71.767 ops/s
LongTextParseTest.prettyFastjson1 thrpt 5 5118.231 ± 31.292 ops/s
LongTextParseTest.prettyFastjson2 thrpt 5 6830.779 ± 46.084 ops/s
LongTextParseTest.prettyJackson thrpt 5 2910.411 ± 37.276 ops/s
LongTextParseTest.prettyWastjson thrpt 5 9459.602 ± 210.523 ops/s
~~~
测试类: https://github.com/wycst/wast-jmh-test/blob/main/src/main/java/com/jmh/test/json/bean/LongTextParseTest.java
测试结果: wastjson >> fastjson2 > fastjson1 > jackson
- 反序列化 - 超大长文本测试(180mb)(ops/min)
~~~
Benchmark Mode Cnt Score Error Units
SuperLongText.fastjson thrpt 5 25.945 ± 10.596 ops/min
SuperLongText.fastjson2 thrpt 5 20.453 ± 17.898 ops/min
SuperLongText.jackson thrpt 5 21.170 ± 0.432 ops/min
SuperLongText.wastjson thrpt 5 49.315 ± 12.184 ops/min
~~~
测试类: https://github.com/wycst/wast-jmh-test/blob/main/src/main/java/com/jmh/test/json/bean/SuperLongText.java
测试结果: wastjson >> fastjson > jackson > fastjson2
- 通过流读取超大长JSON文本测试(180mb)(ops/min)
~~~
Benchmark Mode Cnt Score Error Units
ReadInputStreamTest.jackson thrpt 5 17.911 ± 3.584 ops/min
ReadInputStreamTest.wastjson thrpt 5 27.118 ± 10.143 ops/min
~~~
测试类: https://github.com/wycst/wast-jmh-test/blob/main/src/main/java/com/jmh/test/json/bean/ReadInputStreamTest.java
测试结果: wastjson >> jackson
(fastjson无法读取超大文本流没有加入)
- 序列化 - 中长文本(ops/ms)
~~~
Benchmark Mode Cnt Score Error Units
WriteTest.escapeFastjson thrpt 5 248.960 ± 2.526 ops/ms
WriteTest.escapeFastjson2 thrpt 5 134.715 ± 0.727 ops/ms
WriteTest.escapeJackson thrpt 5 285.107 ± 4.332 ops/ms
WriteTest.escapeWastjson thrpt 5 365.724 ± 16.478 ops/ms
WriteTest.fastjson thrpt 5 528.649 ± 24.377 ops/ms
WriteTest.fastjson2 thrpt 5 372.189 ± 3.944 ops/ms
WriteTest.jackson thrpt 5 329.733 ± 2.537 ops/ms
WriteTest.wastjson thrpt 5 571.830 ± 1.658 ops/ms
~~~
测试类: https://github.com/wycst/wast-jmh-test/blob/main/src/main/java/com/jmh/test/json/bean/WriteTest.java
测试结果:
常规文本: wastjson > fastjson > fastjson2 > jackson
转义文本: wastjson > jackson > fastjson > fastjson2
- json提取性能(局部解析) (ops/ms)
~~~
Benchmark Mode Cnt Score Error Units
JSONPathTest.fastjsonReaderAuthors thrpt 5 454.894 ± 12.225 ops/ms
JSONPathTest.fastjsonReaderPrices thrpt 5 455.360 ± 2.692 ops/ms
JSONPathTest.fastjsonReaderTop2Author thrpt 5 555.557 ± 23.740 ops/ms
JSONPathTest.wastAuthors thrpt 5 801.320 ± 56.132 ops/ms
JSONPathTest.wastPrices thrpt 5 908.480 ± 26.998 ops/ms
JSONPathTest.wastTop2Authors thrpt 5 1451.135 ± 19.843 ops/ms
~~~
测试类: https://github.com/wycst/wast-jmh-test/blob/main/src/main/java/com/jmh/test/json/path/JSONPathTest.java
测试结果:wastjson(JSONNode) >> fastjson2
## 表达式引擎
spel(mvel2, ognl, Fel等库性能和spel差距有点大就不考虑加入评测)
解释模式(非编译模式)
~~~
Benchmark Mode Cnt Score Error Units
ExpressionTest.spelDirectDynamicExpr thrpt 5 3636.816 ± 119.516 ops/s
ExpressionTest.spelDirectStaticExpr thrpt 5 3647.830 ± 103.602 ops/s
ExpressionTest.spelParseDynamicExpr thrpt 5 1638805.101 ± 261375.252 ops/s
ExpressionTest.wastDirectDynamicExpr thrpt 5 4519.986 ± 257.351 ops/s
ExpressionTest.wastDirectStaticExpr thrpt 5 4563.065 ± 68.228 ops/s
ExpressionTest.wastParseDynamicExpr thrpt 5 3172853.345 ± 355515.730 ops/s
~~~
测试类: https://github.com/wycst/wast-jmh-test/blob/main/src/main/java/com/jmh/test/expression/ExpressionTest.java
测试结果:wast > spel
## yaml
org.snakeyaml库(暂时未发现有其他的yaml库)
~~~
Benchmark Mode Cnt Score Error Units
YamlTest.snakeyaml thrpt 5 26.687 ± 0.832 ops/ms
YamlTest.wastYaml thrpt 5 548.392 ± 2.784 ops/ms
~~~
测试类: https://github.com/wycst/wast-jmh-test/blob/main/src/main/java/com/jmh/test/yaml/YamlTest.java
测试结果:wast >> snakeyaml