minhajuddin
https://github.com/minhajuddin/benchmark-large-json-parsing
Benchmark large json parsing
A few crude benchmarks for Elixir, Golang and Ruby
Processor Intel(R) Core(TM) i7-5820K CPU @ 3.30GHz
OS: Ubuntu 16.04
10mb.json
Golang [jq]
$ time jq '.' data/10mb.json > /dev/null
real 0m0.567s
user 0m0.551s
sys 0m0.016s
Elixir
Time taken [Poison]: 1218.831ms
Time taken [Jason]: 508.461ms
Ruby
time ruby app.rb
real 0m0.220s
user 0m0.203s
sys 0m0.017s
100mb.json (sf-city-lots-json/citylots.json at master · zemirco/sf-city-lots-json · GitHub)
Golang [jq]
$ time jq '.' data/citylots.json > /dev/null
real 0m14.436s
user 0m13.992s
sys 0m0.420s
Elixir
Time taken [Poison]: 32_640.87ms
Time taken [Jason]: 11_602.128ms
Ruby
$ time ruby app.rb
real 0m4.738s
user 0m4.498s
sys 0m0.240s
Trending in Discussions
As the title says, please share what you’ve been up to with Elixir. Whether that’s been learning it, looking into it, making stuff with i...
New
I want to open this thread for you all to discuss and help those who really like Ash but are still hesitant to use it in a real project. ...
New
I am happy to introduce the very α version of the new programming language compiled to BEAM.
Welcome Cure.
It has literally three kille...
New
I’m posting this in response to Jose’s recent tweet (Cr. link) :
People are sleeping on Elixir for a coding harness:
Hot-code swappi...
New
Hello,
I wrote Stop My Hand, a Scattergories-like web application using Phoenix/LiveView as my learning project for Elixir (after readin...
New
AcmeScript — Writing JS hooks as if I were still using Elixir
I’ve been having fun building a little something over the last few days: Ac...
New
It would be helpful to have a list of companies worldwide that hire engineers without prior experience in Elixir. Often, it can be quite ...
New
Other Trending Topics
Hobbes is a low-level distributed database for the Elixir programming language.
Hobbes provides a simple, safe, and scalable storage lay...
New
Beam Bots (or just BB for short) is a framework for building fault-tolerant robotics applications in Elixir using familiar OTP patterns. ...
New
ExRatatui lets you cook up rich terminal UIs in Elixir, powered by Rust’s ratatui via Rustler NIFs. Build interactive terminal applicatio...
New
Hello everyone. After busy few months I am happy to announce v0.1.0 of Emerge & Solve.
They are GUI (Emerge) and State management (S...
New
Corex is an accessible, unstyled UI component library for Phoenix that integrates Zag.js state machines using Vanilla JavaScript and Live...
New
There are three potential reasons for members of this forum to have a look at https://vutuv.de
You are tired or annoyed of LinkedIn.
Yo...
New
Categories:
Sub Categories:
Forums
Popular Tags
- #ecto
- #liveview
- #troubleshooting
- #learning-elixir
- #deployment
- #library
- #erlang
- #testing
- #genserver
- #mix
- #absinthe
- #remote-other
- #otp
- #plug
- #how-to-question
- #macros
- #postgres
- #elixirconf
- #channels
- #exunit
- #discussion
- #code-sync
- #podcasts
- #javascript
- #onsite
- #dialyzer
- #docker
- #authentication
- #umbrella
- #full-time-contract
- #podcasts-by-brainlid
- #ecto-query
- #blog-post
- #elixirconf-us
- #elixir-ls
- #ai
- #phoenix_html
- #iex
- #graphql
- #genstage
- #websockets
- #supervisor
- #advent-of-code
- #distillery
- #processes
- #api
- #forms
- #hex
- #security
- #metaprogramming










Showing Posts 1 to 10- Show Best Posts
- Show All (oldest first)
- Show All (newest first)
amnu3387
Does this mean Ruby San, is the fastests fasters ?
(btw shouldn’t this be done with benchee or so?)
brightball
Seems about right. Would be nice to have Jiffy in there as well just for comparison sake.
One important thing to consider when looking at those numbers: the Go and Elixir solutions are written in pure Go and pure Elixir respectively.
I don’t know what they’re using on the Ruby side but most efficient code in Ruby/Python/PHP/Perl is just directly calling C.
michalmuskala
The Ruby parser is implemented in C, so it’s more like comparing C to Elixir. Obviously C is going to be faster
We’re not doing that bad actually. It would be interesting to compare with Jason compiled with HiPE. In my benchmarks this makes it at least twice as fast.
The data is also quite different from what you’d face in a regular HTTP app - the JSON is pretty-printed, most JSON flying on the wire is not. This can have significant difference in the actual performance. Depending on what you want to learn from this, it can be important.
Shikada
There’s exactly 0 chance that Ruby is not just calling some C lib for this
Still, for native Elixir this is reassuringly fast.
brightball
Don’t suppose you’d be up for tweaking the Techempower benchmarks for Elixir to use Jason with HiPE. It’s the basis for the results of so much of those tests I think it would go a long way with the report.
OvermindDL1
Let’s have some fun, here is how they compare to C++/rapidjson:
Admittedly this benchmark is flawed because
jqis outputting to stdout and elixir/ruby/C++ are just kind of blackholing the data after it is parsed, so jq/go is artificially limited here. In addition the elixir version is actually instancing a tree to hold the whole structure, which is wasted work as well (unsure about ruby). The C++ version is fully parsing and performing callbacks for every parse (standard sax parsing).I can PR the C++ one in it if you want, it only needs the normal C++ compiler and cmake installed, nothing else needed (not even rapidjson, it acquires it itself).
OvermindDL1
Just to make sure, here is the C++ version as both a sax parser, and as an elixir-style-structure-building document parser (yay eating memory):
Not much of a difference, honestly the C++ compiler is so good that it is probably being optimized out, hmm…
EDIT: And I added some code to print out some details about the structure to ensure it is compiled and parsed in full and it somehow got a few milliseconds faster… so yeah those are accurate, C++ is just fast as always…
minhajuddin
Would love a PR
minhajuddin
You are right about jq doing more work, I’ll use the standard json parser and make it match the ruby and elixir versions.
Not sure you mean by this:
Elixir would parse the data and have it in memory.
The C++ version seems insane, I’d love to add a Rust benchmark too. I know this is all crude benchmarking but it gives you a sense of comparison.
minhajuddin
I didn’t use Benchee because the run times are fairly large. I’ll see if I can add benchee with small json loads.