Comments (3)
@vzsg Thanks for doing that! - I'll try and make some time for profiling this soon.
from jay.
There are performance tests in the test suite, so you could try to run those on the other parsers and compare? Let me know if you do! (I'm curious as well)
from jay.
I had some free time (and some insomnia), so I played around Jay and two readily available alternatives: JSONSerialization and PerfectLib. OP's other libraries are pure C with very different semantics, for which I lack both the patience and the experience to wrap for Swift.
Using sample data from here, and the benchmark classes from here, I hacked together a benchmark that loops through the parsers and the input files, parses the data 200 times, and measures the time taken by the actual JSON parsing.
Environment:
- 2015 MBP (Core i5 2.7GHz, 8 GB RAM, power adapter)
- macOS 10.12.3 Beta (16D12b)
- Swift 3.0.2 (built in release mode, default optimization settings)
Results:
Source file (size) | Library | Average time | RSD |
---|---|---|---|
actionLabel.json (872) | JSONSerialization | 0.088701ms | 35.2% |
Jay | 0.27735ms | 42.6% | |
PerfectLib | 0.192724ms | 56.7% | |
citm_catalog.json (1727204) | JSONSerialization | 10.5ms | 13.0% |
Jay | 195.0ms | 1.7% | |
PerfectLib | 134.4ms | 1.9% | |
medium.json (2202) | JSONSerialization | 0.110465ms | 26.9% |
Jay | 0.516045ms | 32.2% | |
PerfectLib | 0.382738ms | 37.7% | |
menu.json (276) | JSONSerialization | 0.082635ms | 119.9% |
Jay | 0.109255ms | 24.4% | |
PerfectLib | 0.086137ms | 107.8% | |
sgml.json (705) | JSONSerialization | 0.078692ms | 30.1% |
Jay | 0.178616ms | 25.3% | |
PerfectLib | 0.135693ms | 90.1% | |
small.json (42) | JSONSerialization | 0.077599ms | 29.9% |
Jay | 0.050222ms | 25.5% | |
PerfectLib | 0.0388ms | 30.7% | |
webxml.json (4054) | JSONSerialization | 0.145353ms | 26.1% |
Jay | 1.006042ms | 33.1% | |
PerfectLib | 0.755938ms | 34.0% | |
widget.json (761) | JSONSerialization | 0.114966ms | 40.3% |
Jay | 0.279561ms | 24.0% | |
PerfectLib | 0.189957ms | 25.9% |
Takeaway:
There seems to be something very weird going on while parsing citm_catalog.json (~1,7 MBs) with both Swift libraries. That slow down is huge.
from jay.
Related Issues (20)
- Offer API to expose source maps of parsed JSON documents HOT 4
- Add unwrapping convenience functions HOT 1
- Add header documentation
- CocoaPods HOT 2
- Swift 3?
- Add support for JSON comments HOT 1
- Also escape other whitespace control characters
- Also conform to RFC7159 HOT 4
- Incorrect String->Int map detection HOT 8
- UTF-16 unsupported HOT 4
- Offer a String API HOT 7
- Cannot parse JSON with integer values bigger than Int.max HOT 1
- dataFromJson() Int 0,1 exchange Bool
- Incorrect parsing of Double values if the fraction part starts with zeroes
- Add JSON text visual formatting options
- Tagging a new version HOT 2
- Can't parse exponents that starts with zero
- Purpose of Jay struct HOT 2
- Investigate better way to detect/validate passed-in JSON object
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from jay.