Skip to content
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Go to file
Cannot retrieve contributors at this time
require 'benchmark'
require 'yaml'
require 'json' # gem install json
hash = {
:name => 'Xavier',
:age => 24,
:likes => ["Climbing", "Computers", "Food"]}
n = 10000
marshal_hash = Marshal.dump(hash)
yaml_hash = YAML.dump(hash)
json_hash = JSON.dump(hash) do |b|"Marshal serialize") do
n.times { Marshal.dump(hash) }
end"Marshal deserialize") do
n.times { Marshal.load(marshal_hash) }
end"JSON serialize") do
n.times { JSON.dump(hash) }
end"JSON deserialize") do
n.times { JSON.load(json_hash) }
end"YAML serialize") do
n.times { YAML.dump(hash) }
end"YAML deserialize") do
n.times { YAML.load(yaml_hash) }
require 'psych'"Psych serialize") do
n.times { Psych.dump(hash) }
end"Psych deserialize") do
n.times { Psych.load(yaml_hash) }