Giter Site home page Giter Site logo

csv-benchmark's Introduction

csv-benchmark

Project for benchmarking high-performance open source CSV parsers using JMH.

Bugs, feature suggestions and help requests can be filed with the issue-tracker.

License

Apache 2.0

Obtain

The project is based on Gradle.

Usage

Modify the build version to your current snapshot, and potentially change the include expression in jmh-benchmark/build.gradle and/or the CsvParam to scope your tests.

Then run

./gradlew clean jmhClasses jmh --info

If the JMH plugin seems to have trouble refreshing the project, restart the Gradle deamon before running:

./gradlew --stop && ./gradlew clean jmhClasses jmh --info

And also optionally refresh the dependencies using

./gradlew --stop && ./gradlew clean jmhClasses jmh --refresh-dependencies --info

Open the file ./jmh-benchmark/build/reports/jmh/index.html to view a visualization of the results.

Benchmarks

Inputs:

  • World cities
  • GTFS Trips
  • GTFS StopTimes

Modes:

  • plain or quoted
  • rows in intervals from 1 to 1 million
  • single-shot and sample time
  • databinding or raw String parsing

Results

From using JDK 8 build 232.

Single-shot

What is measured is the cold start, which is how long the parsing take the first time. As much as possible, this includes things like class-loading and inital configuration / creation from a Reader.

The results must be taken with a grain of salt. Most of these will differ quite a lot from run to run, but the current results give a ballpark picture of the performance.

The results show that the SimpleFlatMapper beats univocity-parsers when file size increases. However sesseltjonna-csv performs better than both.

Sample time

What is measured here is the warm start, which is how long the parsing takes after an initial warmup (i.e. for repeated use). The warmup here referes to the Just-in-time-compilator to do its optimizations, which takes place after something like a second of back to back invocation of the code. Basically these optimizations usually mean inlining methods and compiling the bytecode to platform-specific native code.

Below 1000 rows takes at most 1.1 milliseconds for all libraries, 1 million rows takes less than a second: 10000-1000000.

SimpleFlatMapper beats sesseltjonna-csv in one of the raw String benchmarks, otherwise is it quite consistenly sesseltjonna-csv fastest, SimpleFlatMapper second and univocity-parsers third.

When parsing a lot of different CSV file formats, libraries using a static parser implementation will have an advantage on the JIT side as there will be fewer files to compile and thus more of the overall time will be spent running JIT-optimized code paths. In practice though, the number of CSV files (and ordering of the columns) is usually limited.

Bootstrap time

Just a note on using this library to minimize startup time - your milage will vary in relation to the above benchmark because you also have to take into account the time loading the dependency libraries - indeed this is true for all the CSV parser libraries.

For sesseltjonna-csv, when using explicit setter, it loads the byte-buddy library to identify the setter method, whereas the default is to use reflection.

If however the CSV format is written in stone, it is possible to add the dynamically generated parser as regular class during build-time.

So as with all optimization, make sure to measure the startup time before and after modifications.

Links

Alternative benchmarks

History

  • 1.0.2: Added String-array benchmarks, made single-shot benchmarks do most of the classloading.
  • 1.0.1: Bumped versions, refreshed results.
  • 1.0.0: Initial version

csv-benchmark's People

Contributors

skjolber avatar

Stargazers

 avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

csv-benchmark's Issues

Validate benchmarks

The benchmarks are showing very good results, it would be interesting to get some more eyes on and also running them on more hardware.

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.