JSON vs XML: The Fairy-Wing Throwdown Thursday, March 31, 2011


  1. Is XML parsing more than an order of magnitude (i.e., 10x) slower than JSON parsing in real world situations?
  2. Both @pauldix and @flavorjones think XML parsing is slower than than JSON parsing.
  3. @pauldix says XML parsing is more than an order of magnitude slower than JSON parsing.
  4. @flavorjones says XML parsing is less than an order of magnitude slower than JSON parsing.
  5. The loser must wear @flavorjones’s daughter’s dress-up fairy wings on stage throughout @pauldix’s RailsConf 2011 presentation.
  6. 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




How much slower, exactly, is XML in the real world?

(A One Act Drama)

Dramatis Personae

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.

(John shrugs.)

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.

Exeunt omnes.

Tentative Conditions

  1. Benchmarks must be performed on Ruby 1.8.7 with any standard compiled extensions / gems.
  2. Objective is a specific data structure actually used by these Gentlemen at their place of business, Benchmark Solutions.
  3. Code must take a string (JSON or XML), and return an inflated Ruby data structure exactly matching the objective.
  4. Timing should encompass only in-memory operations (not IO).
  5. @jvshahid will be the arbiter of whether the implementations violate the spirit of “real worldiness”.