Skip to content

Instantly share code, notes, and snippets.

@spangenberg
Created July 25, 2014 08:20
Show Gist options
  • Select an option

  • Save spangenberg/ac6e54dc2a7b431932a0 to your computer and use it in GitHub Desktop.

Select an option

Save spangenberg/ac6e54dc2a7b431932a0 to your computer and use it in GitHub Desktop.
Ruby EDN vs. JSON benchmark
require "active_support/json"
require "benchmark"
require "edn"
require "json"
n = 1_000_000
obj = { :hallo => "wie", :get => { :es => ["dir", 2] } }
json = obj.to_json
edn = obj.to_edn
Benchmark.bm(21) do |x|
x.report("EDN:") { n.times { EDN.read(edn) } }
x.report("ActiveSupport::JSON:") { n.times { ActiveSupport::JSON.decode(json) } }
x.report("JSON:") { n.times { JSON.parse(json) } }
end
user system total real
EDN: 126.760000 0.360000 127.120000 (127.831786)
ActiveSupport::JSON: 8.000000 0.150000 8.150000 ( 8.203449)
JSON: 7.410000 0.120000 7.530000 ( 7.547344)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment