Skip to content

Instantly share code, notes, and snippets.

@morten
Last active September 29, 2015 12:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save morten/1598652 to your computer and use it in GitHub Desktop.
Save morten/1598652 to your computer and use it in GitHub Desktop.
require 'benchmark'
require 'psych'
require 'yaml'
data = [ 1 , { "hello hello" => "moo moo", :aaa => [] } ] * 100
yaml = YAML.dump(data)
time = Benchmark.realtime { 10000.times { YAML.load(yaml) }}
puts "Time #{YAML}: #{time}"
YAML::ENGINE.yamler = "syck"
time = Benchmark.realtime { 10000.times { YAML.load(yaml) }}
puts "Time #{YAML}: #{time}"
__END__
~/tmp$ ruby -v test.rb
ruby 1.9.3p0 (2011-10-30 revision 33570) [x86_64-darwin11.2.0]
malloc_limit=100000000 (8000000)
heap_min_slots=500000 (10000)
Time Psych: 15.395857
Time Syck: 3.098056
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment