Skip to content

Commit

Permalink
ADD: benchmarks
Browse files Browse the repository at this point in the history
  • Loading branch information
RicardoJiang committed Oct 3, 2023
1 parent 1639bab commit 1ca93b4
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
9 changes: 8 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,14 @@ The code of nullability check has been optimized carefully which is generated by

We also find out that Kudos.Gson performs better than Moshi on initializing. So it should be a better choice for low frequency deserialization scenarios with both performance(comparing to Moshi) and null safety(comparing to Gson).

>**TIPS**: We are working on a benchmarks project on JSON tools and will bring it out later on.
| | small json | medium json | large json |
|---------------|----------------|----------------|----------------|
| Gson | 412,375 ns | 1,374,838 ns | 3,641,904 ns |
| Kudos-Gson | 517,123 ns | 1,686,568 ns | 4,311,910 ns |
| Jackson | 1,035,010 ns | 1,750,709 ns | 3,450,974 ns |
| Kudos-Jackson | 1,261,026 ns | 2,030,874 ns | 3,939,600 ns |

For more detail, see [https://github.com/RicardoJiang/json-benchmark](https://github.com/RicardoJiang/json-benchmark)

## Version Support

Expand Down
9 changes: 8 additions & 1 deletion README_zh.md
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,14 @@ val list = kudosGson().fromJson("""[null]""", typeOf<KudosList<User>>().javaType

在解析 JSON 时,考虑到冷启动的初始化耗时的情况,Kudos.Gson 比 Moshi 在大部分测试下性能更优(只有在多次解析同一数据类型时 Moshi 性能表现更好),因此 Kudos.Gson 在低频次的 JSON 解析场景下兼具了运行性能(优于 Moshi)和数据安全(优于 Gson)的优点。

>**说明** 详细数据和原始的测试工程仍然在开发当中,后续再进行补充。
| | small json | medium json | large json |
|---------------|----------------|----------------|----------------|
| Gson | 412,375 ns | 1,374,838 ns | 3,641,904 ns |
| Kudos-Gson | 517,123 ns | 1,686,568 ns | 4,311,910 ns |
| Jackson | 1,035,010 ns | 1,750,709 ns | 3,450,974 ns |
| Kudos-Jackson | 1,261,026 ns | 2,030,874 ns | 3,939,600 ns |

更多细节可见:[https://github.com/RicardoJiang/json-benchmark](https://github.com/RicardoJiang/json-benchmark)

## 版本兼容

Expand Down

0 comments on commit 1ca93b4

Please sign in to comment.