GithubHelp home page GithubHelp logo

rubensworks / test-performance-json-parse-stream Goto Github PK

View Code? Open in Web Editor NEW
0.0 2.0 1.0 7 KB

basic measurements that measure the performance and continuous memory usage of several streaming JSON parsers for JavaScript

License: MIT License

JavaScript 100.00%

test-performance-json-parse-stream's Introduction

Performance measurements of streaming JSON parsers

This repo contains some basic measurements that measure the performance and continuous memory usage of several streaming JSON parsers for JavaScript.

Note that this repo does not aim to be a fully-fledged benchmark. It's just a small test for myself.

Considered metrics:

  • Execution time
  • Memory usage
  • Robustness (unit tests)
  • Usage (number of dependents)
  • Maintained (last release)

Tested libraries

Executing these measurements

First, clone this repo.

Then, install and execute it with some JSON file:

$ npm install
$ node --expose-gc index.js some-file.json

In my experiments, the input JSON file (144,2MB) was created as follows:

$ npm install -g @comunica/actor-init-sparql
$ comunica-sparql https://fragments.dbpedia.org/2016-04/en 'construct where { ?s ?p ?o } limit 1000000' -t application/ld+json > dbpedia-1m.jsonld

Results

Results obtained by executing on MacBook Pro (13-inch, 2020, Four Thunderbolt 3 ports); 2,3 GHz Quad-Core Intel Core i7; 16 GB 3733 MHz LPDDR4

Library Execution time Memory Robustness Usage Maintained Notes
stream-json 3.626s 65MB High 139 June 2021 Extensive documentation
jsonparse 2.791s 384MB High 175 2017 Accumulates memory!
SAX variant of jsonparse 1.431s 72MB Low 0 / Not a proper npm package
clarinet 2.213s 67MB High 33 2019

Conclusion

Performance-wise, the SAX variant of jsonparse is the clear winner. However, since it is unmaintained, and no tests are available, it is not recommended.

While jsonparse itself is also pretty fast, it suffers from memory issues for large streams (as it still accumulates JSON in memory). So this is also a no-go.

stream-json and clarinet both have acceptable performance and memory usage. While stream-json is slower than clarinet, it seems to be much better maintained, and has extensive documentation and a broader usage.

Therefore, even though stream-json is slower, it may be considered the best library available at the moment for parsing JSON in a streaming manner.

License

This software is written by Ruben Taelman.

This code is released under the MIT license.

test-performance-json-parse-stream's People

Contributors

rubensworks avatar

Watchers

 avatar  avatar

Forkers

tpt

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.