https://github.com/quanvo87/jsonperf
Performance comparison of JSONDecoder and JSONSerializaton.
https://github.com/quanvo87/jsonperf
decoding json json-serialization swift-evolution swiftyjson
Last synced: about 1 month ago
JSON representation
Performance comparison of JSONDecoder and JSONSerializaton.
- Host: GitHub
- URL: https://github.com/quanvo87/jsonperf
- Owner: quanvo87
- Created: 2017-05-22T04:35:15.000Z (about 9 years ago)
- Default Branch: master
- Last Pushed: 2017-07-25T02:45:06.000Z (almost 9 years ago)
- Last Synced: 2025-05-29T06:43:49.337Z (about 1 year ago)
- Topics: decoding, json, json-serialization, swift-evolution, swiftyjson
- Language: Swift
- Homepage:
- Size: 896 KB
- Stars: 0
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# jsonPerf
Performance comparison of `JSONDecoder` and `JSONSerializaton` decoding and returning a struct from a 7 MB JSON.
- [swift-evolution/0166](https://github.com/apple/swift-evolution/blob/master/proposals/0166-swift-archival-serialization.md)
- [swift-evolution/0167](https://github.com/apple/swift-evolution/blob/master/proposals/0167-swift-encoders.md)

macOS: `JSONEncoder` was 10.95% *slower* than `JSONSerialization` + object mapping.

Linux: `JSONEncoder` was 0.28% *faster* than `JSONSerialization` + object mapping.
### Notes
The `JSONEncoder` bars show performance of `decoder.decode()` where `decoder` is a previously instantiated `JSONDecoder`.
The `JSONSerialization` bars show the total performance of `JSONSerialization.jsonObject`, a cast of that return value to `[String: Any]`, and then instantiating a struct from that dictionary.
## Credits
Borrowed ideas from [JSONShootout](https://github.com/bwhiteley/JSONShootout). Also using their large JSON file.