Skip to content

Instantly share code, notes, and snippets.

@bantic
Created January 21, 2009 16:27
Show Gist options
  • Save bantic/50025 to your computer and use it in GitHub Desktop.
Save bantic/50025 to your computer and use it in GitHub Desktop.
>> require 'rubygems'
=> false
>> require 'benchmark'
=> false
>> require 'yaml'
=> false
>> Benchmark.bmbm do |x|
?> x.report("yaml") { 100_000.times do ; ary = [1,2,3,4,5]; YAML.load(ary.to_yaml); end}
>> x.report("marshal") {100_000.times do ; ary = [1,2,3,4,5]; Marshal.load(Marshal.dump(ary)); end}
>> end
Rehearsal -------------------------------------------
yaml 13.810000 0.060000 13.870000 ( 14.514593)
marshal 0.570000 0.000000 0.570000 ( 0.571853)
--------------------------------- total: 14.440000sec
user system total real
yaml 13.610000 0.020000 13.630000 ( 13.679500)
marshal 0.520000 0.010000 0.530000 ( 0.589022)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment