- Is XML parsing more than an order of magnitude (i.e., 10x) slower than JSON parsing in real world situations?
- Both @pauldix and @flavorjones think XML parsing is slower than than JSON parsing.
- @pauldix says XML parsing is more than an order of magnitude slower than JSON parsing.
- @flavorjones says XML parsing is less than an order of magnitude slower than JSON parsing.
- The loser must wear @flavorjones’s daughter’s dress-up fairy wings on stage throughout @pauldix’s RailsConf 2011 presentation.
- Benchmarks must be performed by close of business Friday, April 1. (No, this is not an April Fool's joke.)
And man, I hope Confreaks is filming it.
The Fairy-Wing Throwdown
JSON v XML
How much slower, exactly, is XML in the real world?
(A One Act Drama)
- Mike (@flavorjones), Nokogiri Mother, Righter of Wrongs.
- Paul (@pauldix), A Knave.
- John (@jvshahid), An Instigator.
Act I, Scene I
Cast is gathered together, drinking beverages, nerding.
John: Hark! My love for Scala knows no bounds. Also, Ruby is Not Half Bad.
Mike: Rememberest thou when we first met? You had time and love for naught but Java and its dear-lov’d cousin, strong static typing.
Chorus: And don’t forget XML!
Paul: Ha ha! Java doth go nowhere without bountiful XML following it around like a little puppy.
Mike: Ha ha! And aided by Spring’s alchemy you wrote Java in XML!
Chorus: Ha ha!
John: A cold and drowsy humour to hear you mock XML so.
Chorus: Why dost thou wring thy hands?
John: Because Nokogiri hath been brought forth from his loins, and he hath intimate knowledge of XML.
Mike: Aye, I know it well, and thus my disaffection has measure and reason. In particular, namespaces are really quite broken.
Paul: Plus, it’s SO SLOW.
John: Gentle Dix, put thy rapier up.
Paul: I do protest I never injur’d thee! I would wager that XML has got to be an order of magnitude slower than JSON, at least!
Mike: (to John) Forbear this outrage? For shame.
Mike: Knowest I libxml2 so well, it is mos def dishonorably slow. But an order of magnitude? I will take that bet.
Paul: I am not affrighted, nor have I need for your money.
Mike: Then … let’s make it … interesting.
- Benchmarks must be performed on Ruby 1.8.7 with any standard compiled extensions / gems.
- Objective is a specific data structure actually used by these Gentlemen at their place of business, Benchmark Solutions.
- Code must take a string (JSON or XML), and return an inflated Ruby data structure exactly matching the objective.
- Timing should encompass only in-memory operations (not IO).
- @jvshahid will be the arbiter of whether the implementations violate the spirit of “real worldiness”.