Commentaires sur : JSON : les performances entre SwiftyJSON et Freddy http://swift-tuto.fr/177/json-les-performances-entre-swiftyjson-et-freddy/ Tutoriels, articles, astuces, ressources pour les développeurs Sat, 06 Feb 2016 12:54:57 +0000 hourly 1 https://wordpress.org/?v=6.1.10 Par : yannickl http://swift-tuto.fr/177/json-les-performances-entre-swiftyjson-et-freddy/#comment-22 Sat, 06 Feb 2016 12:25:08 +0000 http://swift-tuto.fr/?p=177#comment-22 En réponse à John Gallagher.

No prob, Google is smart enough to translate from French to English into a intelligible text.

Indeed I forgot the Debug vs Release mode. I didn’t know that NSJSONSerialiation was a release-mode-compiled version, so yes I understand the difference between both.

Of course, I forgot this part in this post, I’m going to update it to point on your benchmark and explain this part. You have convinced me!

Thank you for taking time to bring these clarifications! That’s great.

]]>
Par : John Gallagher http://swift-tuto.fr/177/json-les-performances-entre-swiftyjson-et-freddy/#comment-21 Sat, 06 Feb 2016 05:34:00 +0000 http://swift-tuto.fr/?p=177#comment-21 Disclaimers: I’m one of the authors of Freddy, and I don’t speak French so I’m hoping Google translate did an OK job with your post. 🙂

There are a couple of issues with the benchmarks here. The biggest is that it appears your timing results were run with the project compiled in Debug mode. This severely slows down Freddy (since it’s pure Swift) but doesn’t slow down native/SwiftyJSON at all since they’re using the shipped, release-mode-compiled version of NSJSONSerialization. I ran your benchmarks in release mode, and on my machine, Freddy was a little worse than 2x slower than native. This is very close to our own measurements (https://github.com/bignerdranch/Freddy/wiki/JSONParser); it’s obviously not as fast as we’d like, but it’s much better than being 10x slower.

The second issue is that pure parsing is only part of the story. One of the slowest parts of using NSJSONSerialization from Swift (as SwiftyJSON does) is the runtime downcast from AnyObject to determine which JSON type a particular value is. This benchmark does not include that step, but it’s a step that will be required in any real-world use of SwiftyJSON. If you have a JSON document where you only need to extract a small portion of it, SwiftJSON may very well still be faster, but the difference will close as you need to get more and more of the data out of the JSON.

]]>