Git Product home page Git Product logo

Comments (4)

noahsark769 avatar noahsark769 commented on August 22, 2024

Put up an initial PR at #13, let me know what you think!

from zippyjson.

michaeleisel avatar michaeleisel commented on August 22, 2024

I am curious though: do you control the JSON coming in that can be one of two types for that key? If so, I would recommend using different keys for those types. I also would imagine that it's pretty expensive performance-wise to be throwing exceptions, and that that cost might even dominate the library parsing.

from zippyjson.

noahsark769 avatar noahsark769 commented on August 22, 2024

Unfortunately we don't control this JSON :(

From a parsing perspective, I do agree that it would probably be strictly faster to use different keys, but performance-wise I'm not completely sure what the hit would be - I was under the impression that because of how Swift error handling works, throwing an error has about the same cost as a return.

I profiled the performance for our use case with Apple's JSONDecoder (though haven't run the benchmarks listed in #13 yet) - for the case I profiled we have something like 400,000 objects with a String property which is converted from either a String or Number json type, and about 94% of the CPU time was spent doing bridging to NSDictionary, which makes me hopeful that even with error throwing, ZippyJSON could be significantly faster for our use case.

I'm going to play around with the benchmarks you mentioned in #13 today (thanks for the help there!) and see what effects this error throwing has

from zippyjson.

michaeleisel avatar michaeleisel commented on August 22, 2024

Done in v1.1.0

from zippyjson.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.