https://github.com/nbxxf/json-benchmark
市面上所有json反序列化速度对比,Gson-code-gen 最优
https://github.com/nbxxf/json-benchmark
benchmark benchmarking gson json
Last synced: 2 months ago
JSON representation
市面上所有json反序列化速度对比,Gson-code-gen 最优
- Host: GitHub
- URL: https://github.com/nbxxf/json-benchmark
- Owner: NBXXF
- Created: 2023-12-18T15:48:13.000Z (over 2 years ago)
- Default Branch: master
- Last Pushed: 2023-12-18T15:54:31.000Z (over 2 years ago)
- Last Synced: 2025-07-07T19:45:33.806Z (12 months ago)
- Topics: benchmark, benchmarking, gson, json
- Language: Kotlin
- Homepage:
- Size: 706 KB
- Stars: 4
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README-en.md
Awesome Lists containing this project
README
English | **[简体中文](README.md)**
# json-benchmark
- Use the Jetpack Microbenchmark library for benchmark testing to avoid the impact of CPU frequency reduction and JIT optimization on test results.
- The test case input includes three json files of size 12kb, 78kb, and 238kb to test the impact of json size on deserialization speed.
- The test results are divided into the results after multiple runs and sufficient preheating.
## Test results
### Multi-run test results
| | small json | medium json | large json |
|----------------------|---------------|----------------|---------------|
| gsonAutoAdapter | 248708 ns | 1617912 ns | 4360885 ns |
| Kotlin Serialization | 272427 ns | 2070424 ns | 5915567 ns |
| JSONReader | 478328 ns | 3562876 ns | 10036805 ns |
| FastJson | 297617 ns | 2241065 ns | 8412797 ns |
| JSONObject | 345072 ns | 2796920 ns | 4788937 ns |
| Moshi | 766846 ns | 3839614 ns | 10105642 ns |
| Gson | 863314 ns | 2892755 ns | 6432696 ns |
| Jackson | 3095442 ns | 5201153 ns | 9291294 ns |

## Gson-Code-gen
- gson automatically generates TypeAdapter, which is the fastest and eliminates reflection. Please refer to [gson_plugin](https://github.com/NBXXF/gson_plugin)