Created
September 4, 2014 03:22
-
-
Save yakreved/7d6f77ee6cab77754779 to your computer and use it in GitHub Desktop.
ruby serialization speed test
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 'ruby-prof' | |
require 'factory_girl' | |
require 'date' | |
include FactoryGirl | |
class User | |
def initialize | |
@name= "jkjkj"+Random.rand(200).to_s | |
@birth = Date.today - Random.rand(3) | |
@num = Random.rand(600) | |
end | |
def to_s | |
"<"+@name+ " " + @birth.to_s+ " " + @num.to_s+ ">" | |
end | |
end | |
list = [] | |
1_000_000.times do | |
list.append(User.new) | |
end | |
#p list | |
RubyProf.start | |
f = File.open( 'peoples.sav', 'w' ) | |
Marshal.dump(list, f ) | |
f.close | |
myfriends = Marshal.load(File.open('peoples.sav' )) | |
result = RubyProf.stop | |
# Print a flat profile to text | |
printer = RubyProf::FlatPrinter.new(result) | |
printer.print(STDOUT) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment