Skip to content

Instantly share code, notes, and snippets.

@janjiss
Created June 17, 2012 22:05
Show Gist options
  • Save janjiss/2945860 to your computer and use it in GitHub Desktop.
Save janjiss/2945860 to your computer and use it in GitHub Desktop.
MongoDB vs MySQL test for creating and destroying 10000 records
# MongoDB vs MySQL test for creating and destroying 10000 recordst.
# Was using faker gem to generate random text for body and content
# Code for Benchmark
def self.do_bm
Benchmark.bm do |x|
x.report do
10000.times do
self.create(:title => Faker::Lorem.sentence, :body => Faker::Lorem.paragraph(10))
end
end
x.report do
self.destroy_all
end
end
end
# In the red corner Rails 3.2.6 with mysql2 gem
# It took 10 min to create 10k records with mysql and 10min to destroy them
# user system total real
# 27.260000 1.100000 28.360000 (628.253261)
# 9.900000 0.870000 10.770000 (632.666397)
# In the red corner Rails 3.2.6 with mongo_mapper
# It took 10 sec to create 10k records with mysql and 10sec to destroy them
# user system total real
# 10.020000 0.230000 10.250000 ( 10.337336)
# 12.110000 0.470000 12.580000 ( 12.856795)
# DEEEEEM
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment