Coder Social home page Coder Social logo

simdjson-java's Introduction

simdjson-java

Build Status

A Java version of simdjson - a JSON parser using SIMD instructions, based on the paper Parsing Gigabytes of JSON per Second by Geoff Langdale and Daniel Lemire.

Code Sample

byte[] json = loadTwitterJson();

SimdJsonParser parser = new SimdJsonParser();
JsonValue jsonValue = parser.parse(json, json.length);
Iterator<JsonValue> tweets = jsonValue.get("statuses").arrayIterator();
while (tweets.hasNext()) {
    JsonValue tweet = tweets.next();
    JsonValue user = tweet.get("user");
    if (user.get("default_profile").asBoolean()) {
        System.out.println(user.get("screen_name").asString());
    }
}

Installation

The library is available in the Maven Central Repository. To include it in your project, add the following dependency to the build.gradle file:

implementation("org.simdjson:simdjson-java:0.1.0")

or to the pom.xml file:

<dependency>
    <groupId>org.simdjson</groupId>
    <artifactId>simdjson-java</artifactId>
    <version>0.1.0</version>
</dependency>

Please remember about specifying the desired version.

Note that simdjson-java follows the SemVer specification, which means, for example, that a major version of zero indicates initial development, so the library's API should not be considered stable.

We require Java 20 or better.

Benchmarks

To run the JMH benchmarks, execute the following command:

./gradlew jmh

Tests

To run the tests, execute the following command:

./gradlew test

Performance

This section presents a performance comparison of different JSON parsers available as Java libraries. The benchmark used the twitter.json dataset, and its goal was to measure the throughput (ops/s) of parsing and finding all unique users with a default profile.

Note that simdjson-java is still missing several features (see GitHub Issues), so the following results may not reflect its real performance.

Environment:

  • CPU: Intel(R) Core(TM) i5-4590 CPU @ 3.30GHz
  • OS: Ubuntu 23.04, kernel 6.2.0-23-generic
  • Java: OpenJDK 64-Bit Server VM Temurin-20.0.1+9
Library Version Throughput (ops/s)
simdjson-java - 1450.951
simdjson-java (padded) - 1505.227
jackson 2.15.2 504.562
fastjson2 2.0.35 590.743
jsoniter 0.9.23 384.664

To reproduce the benchmark results, execute the following command:

./gradlew jmh -Pjmh.includes='.*ParseAndSelectBenchmark.*'

The benchmark may take several minutes. Remember that you need Java 20 or better.

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.