Created
July 25, 2014 08:20
-
-
Save spangenberg/ac6e54dc2a7b431932a0 to your computer and use it in GitHub Desktop.
Ruby EDN vs. JSON benchmark
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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