How's the de/serialization performance of transit?

The EDN supported data type much rich than JSON, Use EDN instead JSON would be more convenient.

But I want to know, how’s the performance de/serialize Clojure data. Have any people do a benchmark about JSON(use cheshire) and EDN(use transit)

I tested it myself, the tranist & json has same performance in encode. In decode, transit little slower than json.

Transit is heavily optimized for performance, and will be much much faster than directly reading/writing EDN.

Directly comparing it to JSON isn’t entirely fair as it’s a much richer format, transit can also reuse references, so if you have the same piece of data twice inside a bigger data structure, it will only be serialized (and deserialized) once.

It seems you’re mostly looking at the JVM side, but when talking to a browser using ClojureScript Transit also has big benefits over JSON, as it deserializes to ClojureScript data structures directly. This is much faster than first using JSON and then converting it with js->clj.

3 Likes

I second that about transit and ClojureScript. We saved a lot of start time for our SPA, switching from JSON to transit.

1 Like

In my tests from a few years ago

(->> str js/JSON.parse js->clj)

was slower than

(->> str transit/read)

Not sure if that’s true anymore, but js->clj used to be very slow, for some reason

1 Like

Beware of this issue when writing transit to a file on disk:

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.