Giter Site home page Giter Site logo

Benchmarks? about json HOT 8 CLOSED

toughengineer avatar toughengineer commented on May 28, 2024
Benchmarks?

from json.

Comments (8)

ColinH avatar ColinH commented on May 28, 2024

These are microbenchmarks that we used during early development. They aren't really intended for end-users. That said:

When you build with make the performance test binaries are automatically built, too. If you build with Cmake then ... the easiest way is probably to move them to src/example/json and modify the CMakeLists.txt file accordingly.

Most of the benchmarks need to be called in the shell with a (large) JSON file, like the ones in the tests directery, to do their thing.

from json.

toughengineer avatar toughengineer commented on May 28, 2024

Do you plan to provide a way to build existing benchmarks with CMake out of the box? Or add new benchmarks?

I have an idea how to make parsing of JSON faster and wanted to experiment. I would like to use common reference point in the form of benchmarks already set up to be built instead of everybody inventing their own way.

from json.

ColinH avatar ColinH commented on May 28, 2024

There are no current plans in that direction. Did you manage to build (and run) the benchmarks?

from json.

toughengineer avatar toughengineer commented on May 28, 2024

I did not try to build it, I guess I will maybe come back to it some other time.

The idea I wanted to experiment with is to parse first small number of JSON array elements (say, 42) into an array (e.g. std::array or plain C-style array, without memory (re)allocation) eventually moving them into the array storage in the value, and only then use push_back/emplace_back. First few push_backs are relatively expensive so temporarily putting parsed elements into an array offsets this cost and makes parsing noticeably faster.

from json.

ColinH avatar ColinH commented on May 28, 2024

I just committed an update to the Cmake configuration that also builds the perf applications. If I remember correctly the only reason to exclude them was that the timing code used to be partially platform dependent, but it has since been changed to use std::chrono and should compile everywhere.

from json.

ColinH avatar ColinH commented on May 28, 2024

Even assuming that you will be using a bulk insert into the vector, you are still copying the elements around and I wonder whether it wouldn't be more efficient to just call reserve() on it before starting to emplace_back() elements. Should be easy to add to the tao::json::events::set_basic_value::begin_array() Events method; the one that takes a std::size_t already does just that.

from json.

toughengineer avatar toughengineer commented on May 28, 2024

Thank you, I'll try to come back to it soon.

Calling reserve() is a potential waste of memory — premature optimization.
In the end it's a tradeoff, if you are OK to maybe waste memory in order to maybe gain speed then go for it. I advocate against using reserve() unless you know the exact number of elements you are going to push_back().

from json.

ColinH avatar ColinH commented on May 28, 2024

Yes, the trade-off between time and space, as old as computer programming ;-)

from json.

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.