Rick

Rick
Rick

Friday, April 18, 2014

FastJSON (Rocky), Mr T. (Boon) wants to take you on for the JSON Java Serialization championship match of the world

Ok.. So I heard a lot about FastJson.

https://github.com/alibaba/fastjson/wiki/_pages

https://github.com/RuedigerMoeller/fast-serialization/wiki/TestPage

Time to pony up to the bar and see how fast FastJSON is....

Interviewer: Do you hate Rocky?
Clubber Lang: No, I don't hate Balboa. I pity the fool, and I will destroy any man who tries to take what I got!


Mr T says I pity the fool who names his parser FastJSON.....

Round 1.
i.g.j.s.MainBoonSerializer.roundTripBig          thrpt  16         3    1      109.539      180.206    ops/s
i.g.j.s.MainFastJsonSerializer.roundTripBig      thrpt  16         3    1       77.767      442.537    ops/s
FastJSON comes out swinging. Boon lands a solid punch on the chin send FastJSON back a few steps and FastJSON wonders what just hit him.
We did not expect this. Wow!


Round 2:
i.g.j.s.MainBoonSerializer.roundTriper           thrpt  16         3    1   322589.867   263964.706    ops/s
i.g.j.s.MainFastJsonSerializer.roundTriper       thrpt  16         3    1   372651.528    60503.278    ops/s
Photo finish, but Boon comes out swinging hard, and FastJSON eeks out a small victory. Time to fire up yourKit and VisualVM.

Round 3
i.g.j.s.MainBoonSerializer.serializeBig          thrpt  16         3    1      386.978       52.936    ops/s
i.g.j.s.MainFastJsonSerializer.serializeBig      thrpt  16         3    1      143.339      130.480    ops/s
Boon body slams FastJSON. Don't call it a come back. Do you smell what the Boon has been cooking?! Boon demolishes FastJSON.


Round 4
i.g.j.s.MainBoonSerializer.serializeSmall        thrpt  16         3    1   970575.272    34411.444    ops/s
i.g.j.s.MainFastJsonSerializer.serializeSmall    thrpt  16         3    1   784787.311    85672.955    ops/s
Sonic Boon! Allyoucan! Triple twirling punch to the chin. The new world champion in Java JSON serialization. The crowd roars. Boon wins! Boon wins! What an upset victory!







What you thought Rocky was going to win? This is not some Hollywood movie fool! How many Italian guys are the world champion boxer of the world? I pity the fool!


Caveat: I have no idea if I am using FastJSON correctly, and I am not 100% sure if this test is even fair. But I think it is. I mean I did not deliberately cheat. And  please note, lack of sleep makes me silly. FASTJson looks very awesome and its ability to keep up with the fastest binary serializers is very impressive too.  This was not the world championship more like a exhibition fight.

FASTJson does all sorts of runtime code gen is my understanding. So it could be that I did not give it enough time to warm up or it could be that although the code gen bought it speed in accessing Java properties, the JSON parser is just slower. I don't really know.

If you found this interesting than a slightly more serious version of this is here:


Which is faster serializing to JSON with Jackson or serializing to binary with ObjectOutputStream? Most people assume that Java object serialization is faster than Jackson JSON serialization because Jackson is using JSON and Java object serialization is binary. Is this true? Find out. http://www.dzone.com/links/which_is_faster_serializing_to_json_with_jackson.html

Then a even more serious with many pretty graphs article is here:

Jackson is consistently faster than GSON and JSONSmart. Boon JSON parser and the new Groovy 2.3 JSON parser are faster than Jackson. They are faster than Jackson with InputStream, Reader, reading files, byte[], and char[] and String. Groovy JSON support and the Boon JSON parser are up to 3x to 5x faster than Jackson at parsing JSON from String and char[], and 2x to 4x faster at parsing byte[].

Looking for a tutorial to get started with Boon?

This five minute guide will get you up to speed using Boon in no time. Parse and serialize Java objects to/fro JSON up to 5x faster! Boon is not a JSON parsing project. It is more than that, but JSON parsing is intrinsic to what Boon is all about. Boon is the fastest way to serialize and parse JSON in Java so far. It is faster at object serialization, enabling JSON expressions, JSON parsing and much more. Boon JSON is FAST! In addition it has a very easy to use, convention-based API. This getting started guide covers making JSON REST calls, JSON object serialization, using annotations, and more.

Need to do ETL with JSON, and/or want to search sort JSON or Java graphs quickly.

Java Boon - Boon Data Repo using Indexed Collections for Java Beans, JSON and Maps like JDK 8 streams but faster. Many languages have sorting, slicing, dicing capabilities for Lists and Maps, and JSON. Boon adds this to Java. Boon Data Repo is an in-memory query engine that can use high speed indexed collections for very fast in-memory queries. This brief tutorial will show you how to use Boon to query JSON, Java objects and Java maps. And also how to do ELT transforms with JSON, Java objects and Java Maps.

Java Boon filtering for Java Beans, JSON and Java Maps like JDK 8 streams but much faster. Many languages have support for querying objects and filtering objects easily. Java does in JDK 8, but Boon adds it as well, and it can compliment features of JDK 8 as well as work in Java 7 land. Boon adds filtering to to Java. You can filter JSON, Java, and Maps. You can also use indexed queries which are a lot faster than linear search queries that come with JDK 8.


Many languages have path expressions. Boon adds this to Java. Boon has powerful path expressions that work with objects, lists and maps. It also works with JSON. Full examples of Java, Maps/Lists and JSON are included in this tutorial.

Just curious about what Boon is...
Boon comes with helper methods that allow you to easily read files, create lists, sets, maps, concurrent maps, sorted maps, sorted sets, etc. It provides slice notation, searching, easy IO (files, http, etc.). The helper methods are safeList, list, set, sortedSet, safeSet,safeSortedSet, etc. The idea is to make Java feel more like list and maps are built-in types.

What if Java collections and Java hierarchies were easily searchable? They are with Boon! What if it were easy to query a complex set of Java objects at runtime? What if there were an API that kept your object indexes (really just TreeMaps, and HashMaps) in sync.? Well then you would have Boon's data repo. This article shows how to use Boon's data repo utilities to query Java objects. Boon comes with a simple criteria API that makes working with Java collections a snap.

Boon has many utility methods to convert objects into maps, lists, JSON, etc. It also has many collection utility methods. One such utility method is deepCopy, which will deep copy a list or set. Programmer as a way to clone Collection e.g. List, Set, ArrayList, HashSet or any other implementation. Or they write a lot of boiler plate code and spend a lot of time doing things to copy lists and sets. With Boon you can do deep copies without messing around with clone.

Boon gets some inspiration from Groovy and Python when dealing with maps, lists and JSON. It addition to adding slice notation and such, which I covered before. Boon has first class support for converting between Maps, List, JSON and Java objects. Boon gets some inspiration from Ruby, Groovy, Python and Perl and aims to make Java programming just a bit more fun.








No comments:

Post a Comment

Kafka and Cassandra support, training for AWS EC2 Cassandra 3.0 Training