Created
May 22, 2013 20:12
-
-
Save rafbm/5630528 to your computer and use it in GitHub Desktop.
Benchmarking Ruby’s JSON.load and JSON.parse.
This file contains 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 'benchmark' | |
require 'json' | |
str = '{"foo": "bar"}' | |
Benchmark.benchmark Benchmark::CAPTION, 11 do |bm| | |
bm.report 'JSON.load' do | |
500_000.times { JSON.load(str) } | |
end | |
bm.report 'JSON.parse' do | |
500_000.times { JSON.parse(str) } | |
end | |
end | |
__END__ | |
user system total real | |
JSON.load 4.840000 0.130000 4.970000 ( 4.986769) | |
JSON.parse 2.410000 0.020000 2.430000 ( 2.428971) | |
Yay JSON.parse! |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Did you try with other parsers? Like
oj
oryajl-ruby
?