Created
October 30, 2011 17:51
-
-
Save paulv/1326186 to your computer and use it in GitHub Desktop.
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
# ruby 1.9.3 was released today. One of the notes in the NEWS file says | |
# | |
# * yaml | |
# * The default YAML engine is now Psych. You may downgrade to syck by setting | |
# YAML::ENGINE.yamler = 'syck'. | |
# | |
# I assumed that psych would be faster than syck, so I ran a test. timeline.yml is | |
# 984K of twitter timeline json converted to yaml. | |
require 'yaml' | |
require "benchmark" | |
Benchmark.bm(10) do |x| | |
x.report("Psych x1:") do | |
YAML::ENGINE.yamler = 'psych' | |
YAML.load_file('timeline.yml') | |
end | |
x.report("Syck x1:") do | |
YAML::ENGINE.yamler = 'syck' | |
YAML.load_file('timeline.yml') | |
end | |
x.report("Psych x10:") do | |
YAML::ENGINE.yamler = 'psych' | |
(1..10).each do | |
YAML.load_file('timeline.yml') | |
end | |
end | |
x.report("Syck x10:") do | |
YAML::ENGINE.yamler = 'syck' | |
(1..10).each do | |
YAML.load_file('timeline.yml') | |
end | |
end | |
end | |
__END__ | |
user system total real | |
Psych x1: 0.760000 0.010000 0.770000 ( 0.781250) | |
Syck x1: 0.260000 0.000000 0.260000 ( 0.262390) | |
Psych x10: 8.100000 0.030000 8.130000 ( 8.188998) | |
Syck x10: 2.820000 0.000000 2.820000 ( 2.870540) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment