clojure.data.json reading:
(dotimes [_ 5] (time (read-json (slurp "foo.json"))))
"Elapsed time: 105137.039484 msecs"
"Elapsed time: 109517.590644 msecs"
"Elapsed time: 114940.018075 msecs"
"Elapsed time: 107612.194846 msecs"
"Elapsed time: 104434.230607 msecs"
nil
clj-json reading:
(dotimes [_ 5] (time (parse-string (slurp "foo.json") true)))
"Elapsed time: 851.541746 msecs"
"Elapsed time: 716.894466 msecs"
"Elapsed time: 713.257132 msecs"
"Elapsed time: 710.379671 msecs"
"Elapsed time: 709.358592 msecs"
nil
clojure.data.json create string:
(def foo (read-json (slurp "foo.json")))
(dotimes [_ 5] (time (json-str foo)))
"Elapsed time: 1546.511918 msecs"
"Elapsed time: 1533.056017 msecs"
"Elapsed time: 1534.136322 msecs"
"Elapsed time: 1537.893503 msecs"
"Elapsed time: 1555.343765 msecs"
nil
clj-json create string:
(def foo (parse-string (slurp "foo.json")))
(dotimes [_ 5] (time (generate-string foo)))
"Elapsed time: 375.415311 msecs"
"Elapsed time: 298.440444 msecs"
"Elapsed time: 272.829368 msecs"
"Elapsed time: 271.800466 msecs"
"Elapsed time: 273.67808 msecs"
nil
The JSON file is about 217KB, with vectors containing a couple of
thousand JSON objects with nested vector objects between 2-6 levels
deep.
Granted, clj-json uses a (presumably heavily optimized) Java library
as the work horse, while clojure.data.json is pure Clojure. However, I
feel the speed penalty is too big of a price to pay in this case. Now,
I can use clj-json for my own parsing needs. However, something like
clutch (couchdb library) that uses c.d.json behind the scenes may be
paying a price in performance that I cannot easily overcome without
hacking around inside it in order to swap JSON implementation, rather
than tweaking my own code (although, in this case it may be limited to
just the JSON string creation).
Perhaps there are benefits (of which I'm not aware) to c.d.json that
are not available in clj-json, but I'd be hard-pressed to come up with
a scenario where I wouldn't pick the significant speed boost of
clj-json.
Lars Nilsson
--
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clo...@googlegroups.com
Note that posts from new members are moderated - please be patient with your first post.
To unsubscribe from this group, send email to
clojure+u...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
Both clj-json and cheshire (https://github.com/dakrone/cheshire) are
actually already based on Jackson.
> I can use clj-json for my own parsing needs. However, something like
> clutch (couchdb library) that uses c.d.json behind the scenes may be
> paying a price in performance
Seems a bit silly if someone's just choosing a slower implementation
just because it's in contrib. I suspect the author of Cheshire may
have plenty of good reasons for not wanting to put his library in
contrib, including the fact that its deps might not line up with
contrib policy, wanting to accept patches without making contributors
mail in paperwork, and wanting to use a better bug tracker than Jira.
-Phil
Lars Nilsson
- Chas
1. JSON transformation is of fundamental importance to many Clojure
applications.
2. Having the "standard" solution be blown away by a factor of 140x
for the sake of purity is not pragmatic.
If the user experience with contrib is to use it, realize its not
ready for prime time, and then go rummaging around through github for
better solutions made by people who've previously realized the same
thing, that is a fail. And makes one less likely to look to contrib
for default solutions to common problems.
Lars Nilsson
As long as we're fixing d.c.json... it would be nice to add support for encoding sequences and maps.
(I know, I should open a bug....)
http://dev.clojure.org/jira/browse/DJSON :)
--
Sean A Corfield -- (904) 302-SEAN
An Architect's View -- http://corfield.org/
World Singles, LLC. -- http://worldsingles.com/
Railo Technologies, Inc. -- http://www.getrailo.com/
"Perfection is the enemy of the good."
-- Gustave Flaubert, French realist novelist (1821-1880)
Login Required
You are not logged in.
You cannot view this URL as a guest. You must log in or sign up for an account .
If you think this message is wrong, please consult your administrators
about getting the necessary permissions.
Lars Nilsson
This reflection warning can be fixed with an enhancement on the
Clojure side, which I have just pushed to master [1].
I would like to create 1.4 alpha 1 with the code changes that have
gone in today. It would be super-great if anybody has time to build
your own project against master and let us know if you see any issues.
Thanks,
Stu
[1] https://github.com/clojure/clojure/commit/405d24dd49d649c01b7881f1394fc90924c54ef0
> --
> You received this message because you are subscribed to the Google
> Groups "Clojure" group.
> To post to this group, send email to clo...@googlegroups.com
> Note that posts from new members are moderated - please be patient with your first post.
> To unsubscribe from this group, send email to
> clojure+u...@googlegroups.com
> For more options, visit this group at
> http://groups.google.com/group/clojure?hl=en
--
And what is good, Phaedrus,
And what is not good—
Need we ask anyone to tell us these things?
Cloning and building 1.4.0-master-SNAPSHOT resulted in much better
performance in loading data into couchdb. When using c.d.json it takes
about 98 seconds for loading and storing 100 JSON documents (ranging
in size from some tens of KB, to 5MB), while clj-json takes about 86
seconds.
Comparing just the load time c.d.json takes 27 seconds and clj-json
takes 12 seconds. Overall, the 100 JSON files are about 114MB. So to
keep things in perspectice, a single 217KB file took over 100 seconds
before this change, now 114MB takes 27 seconds.
Lars Nilsson
Ugh, I need to keep things straight. It was obviuosly some iterations
earlier for the single file, compared with once for each file
afterward. Still, the difference is huge.
Lars Nilsson
I'll try to run tests against 1.4.0-master-SNAPSHOT today (that'll
have this change, right?).
Sean
I get a NPE from the 1.4 compiler on Congomongo. Details reported on
clojure-dev.