Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Forgot to uncomment back the benchmark

  • Loading branch information...
commit fa070e2449915e5021639d342f65e5b1a4b87c55 1 parent 286071c
@durran durran authored
Showing with 216 additions and 216 deletions.
  1. +216 −216 perf/benchmark.rb
View
432 perf/benchmark.rb
@@ -16,289 +16,289 @@
Benchmark.bm do |bm|
- # puts "\n[ Root Document Benchmarks ]"
-
- # [ 1000, 10000, 100000, 1000000 ].each do |i|
-
- # Mongoid.unit_of_work do
-
- # puts "[ #{i} ]"
-
- # bm.report("#create ") do
- # i.times do |n|
- # Person.create(:birth_date => Date.new(1970, 1, 1))
- # end
- # end
-
- # bm.report("#each ") do
- # Person.all.each { |person| person.birth_date }
- # end
-
- # bm.report("#find ") do
- # Person.find(Person.first.id)
- # end
+ puts "\n[ Root Document Benchmarks ]"
- # bm.report("#save ") do
- # Person.all.each do |person|
- # person.title = "Testing"
- # person.save
- # end
- # end
+ [ 1000, 10000, 100000, 1000000 ].each do |i|
- # bm.report("#update_attribute ") do
- # Person.all.each { |person| person.update_attribute(:title, "Updated") }
- # end
+ Mongoid.unit_of_work do
+
+ puts "[ #{i} ]"
+
+ bm.report("#create ") do
+ i.times do |n|
+ Person.create(:birth_date => Date.new(1970, 1, 1))
+ end
+ end
+
+ bm.report("#each ") do
+ Person.all.each { |person| person.birth_date }
+ end
+
+ bm.report("#find ") do
+ Person.find(Person.first.id)
+ end
- # Person.delete_all
- # end
- # end
+ bm.report("#save ") do
+ Person.all.each do |person|
+ person.title = "Testing"
+ person.save
+ end
+ end
- # GC.start
+ bm.report("#update_attribute ") do
+ Person.all.each { |person| person.update_attribute(:title, "Updated") }
+ end
- # person = Person.create(:birth_date => Date.new(1970, 1, 1))
+ Person.delete_all
+ end
+ end
+
+ GC.start
- # puts "\n[ Embedded 1-n Benchmarks ]"
+ person = Person.create(:birth_date => Date.new(1970, 1, 1))
- # [ 1000, 10000 ].each do |i|
+ puts "\n[ Embedded 1-n Benchmarks ]"
- # Mongoid.unit_of_work do
+ [ 1000, 10000 ].each do |i|
- # puts "[ #{i} ]"
+ Mongoid.unit_of_work do
- # bm.report("#build ") do
- # i.times do |n|
- # person.addresses.build(
- # :street => "Wienerstr. #{n}",
- # :city => "Berlin",
- # :post_code => "10999"
- # )
- # end
- # end
+ puts "[ #{i} ]"
- # bm.report("#clear ") do
- # person.addresses.clear
- # end
+ bm.report("#build ") do
+ i.times do |n|
+ person.addresses.build(
+ :street => "Wienerstr. #{n}",
+ :city => "Berlin",
+ :post_code => "10999"
+ )
+ end
+ end
- # bm.report("#create ") do
- # i.times do |n|
- # person.addresses.create(
- # :street => "Wienerstr. #{n}",
- # :city => "Berlin",
- # :post_code => "10999"
- # )
- # end
- # end
+ bm.report("#clear ") do
+ person.addresses.clear
+ end
- # bm.report("#count ") do
- # person.addresses.count
- # end
+ bm.report("#create ") do
+ i.times do |n|
+ person.addresses.create(
+ :street => "Wienerstr. #{n}",
+ :city => "Berlin",
+ :post_code => "10999"
+ )
+ end
+ end
- # bm.report("#delete_all ") do
- # person.addresses.delete_all
- # end
+ bm.report("#count ") do
+ person.addresses.count
+ end
- # person.addresses.clear
- # GC.start
+ bm.report("#delete_all ") do
+ person.addresses.delete_all
+ end
- # bm.report("#push (batch) ") do
- # [].tap do |addresses|
- # i.times do |n|
- # addresses << Address.new(
- # :street => "Wienerstr. #{n}",
- # :city => "Berlin",
- # :post_code => "10999"
- # )
- # end
- # person.addresses.push(addresses)
- # end
- # end
+ person.addresses.clear
+ GC.start
+
+ bm.report("#push (batch) ") do
+ [].tap do |addresses|
+ i.times do |n|
+ addresses << Address.new(
+ :street => "Wienerstr. #{n}",
+ :city => "Berlin",
+ :post_code => "10999"
+ )
+ end
+ person.addresses.push(addresses)
+ end
+ end
- # bm.report("#each ") do
- # person.addresses.each do |address|
- # address.street
- # end
- # end
+ bm.report("#each ") do
+ person.addresses.each do |address|
+ address.street
+ end
+ end
- # address = person.addresses.last
+ address = person.addresses.last
- # bm.report("#find ") do
- # person.addresses.find(address.id)
- # end
+ bm.report("#find ") do
+ person.addresses.find(address.id)
+ end
- # bm.report("#delete ") do
- # person.addresses.delete(address)
- # end
+ bm.report("#delete ") do
+ person.addresses.delete(address)
+ end
- # person.addresses.delete_all
- # end
- # end
+ person.addresses.delete_all
+ end
+ end
- # GC.start
+ GC.start
- # puts "\n[ Embedded 1-1 Benchmarks ]"
+ puts "\n[ Embedded 1-1 Benchmarks ]"
- # [ 1000, 10000 ].each do |i|
+ [ 1000, 10000 ].each do |i|
- # Mongoid.unit_of_work do
+ Mongoid.unit_of_work do
- # puts "[ #{i} ]"
+ puts "[ #{i} ]"
- # bm.report("#relation= ") do
- # i.times do |n|
- # person.name = Name.new(:given => "Name #{n}")
- # end
- # end
- # end
- # end
+ bm.report("#relation= ") do
+ i.times do |n|
+ person.name = Name.new(:given => "Name #{n}")
+ end
+ end
+ end
+ end
- # GC.start
+ GC.start
- # puts "\n[ Referenced 1-n Benchmarks ]"
+ puts "\n[ Referenced 1-n Benchmarks ]"
- # [ 1000, 10000, 100000 ].each do |i|
+ [ 1000, 10000, 100000 ].each do |i|
- # Mongoid.unit_of_work do
+ Mongoid.unit_of_work do
- # puts "[ #{i} ]"
+ puts "[ #{i} ]"
- # bm.report("#build ") do
- # i.times do |n|
- # person.posts.build(:title => "Posting #{n}")
- # end
- # end
+ bm.report("#build ") do
+ i.times do |n|
+ person.posts.build(:title => "Posting #{n}")
+ end
+ end
- # bm.report("#clear ") do
- # person.posts.clear
- # end
+ bm.report("#clear ") do
+ person.posts.clear
+ end
- # bm.report("#create ") do
- # i.times do |n|
- # person.posts.create(:title => "Posting #{n}")
- # end
- # end
+ bm.report("#create ") do
+ i.times do |n|
+ person.posts.create(:title => "Posting #{n}")
+ end
+ end
- # bm.report("#count ") do
- # person.posts.count
- # end
+ bm.report("#count ") do
+ person.posts.count
+ end
- # bm.report("#delete_all ") do
- # person.posts.delete_all
- # end
+ bm.report("#delete_all ") do
+ person.posts.delete_all
+ end
- # person.posts.clear
- # GC.start
+ person.posts.clear
+ GC.start
- # bm.report("#push (batch) ") do
- # [].tap do |posts|
- # i.times do |n|
- # posts << Post.new(:title => "Posting #{n}")
- # end
- # person.posts.push(posts)
- # end
- # end
+ bm.report("#push (batch) ") do
+ [].tap do |posts|
+ i.times do |n|
+ posts << Post.new(:title => "Posting #{n}")
+ end
+ person.posts.push(posts)
+ end
+ end
- # bm.report("#each ") do
- # person.posts.each do |post|
- # post.title
- # end
- # end
+ bm.report("#each ") do
+ person.posts.each do |post|
+ post.title
+ end
+ end
- # post = person.posts.last
+ post = person.posts.last
- # bm.report("#find ") do
- # person.posts.find(post.id)
- # end
+ bm.report("#find ") do
+ person.posts.find(post.id)
+ end
- # bm.report("#delete ") do
- # person.posts.delete(post)
- # end
+ bm.report("#delete ") do
+ person.posts.delete(post)
+ end
- # person.posts.clear
- # GC.start
- # end
- # end
+ person.posts.clear
+ GC.start
+ end
+ end
- # puts "\n[ Referenced 1-1 Benchmarks ]"
+ puts "\n[ Referenced 1-1 Benchmarks ]"
- # [ 1000, 10000, 100000 ].each do |i|
+ [ 1000, 10000, 100000 ].each do |i|
- # Mongoid.unit_of_work do
+ Mongoid.unit_of_work do
- # puts "[ #{i} ]"
+ puts "[ #{i} ]"
- # bm.report("#relation= ") do
- # i.times do |n|
- # person.game = Game.new(:name => "Final Fantasy #{n}")
- # end
- # end
- # end
- # end
+ bm.report("#relation= ") do
+ i.times do |n|
+ person.game = Game.new(:name => "Final Fantasy #{n}")
+ end
+ end
+ end
+ end
- # GC.start
+ GC.start
- # puts "\n[ Referenced n-n Benchmarks ]"
+ puts "\n[ Referenced n-n Benchmarks ]"
- # [ 1000, 10000 ].each do |i|
+ [ 1000, 10000 ].each do |i|
- # Mongoid.unit_of_work do
+ Mongoid.unit_of_work do
- # puts "[ #{i} ]"
+ puts "[ #{i} ]"
- # GC.disable
+ GC.disable
- # bm.report("#build ") do
- # i.times do |n|
- # person.preferences.build(:name => "Preference #{n}")
- # end
- # end
+ bm.report("#build ") do
+ i.times do |n|
+ person.preferences.build(:name => "Preference #{n}")
+ end
+ end
- # GC.enable
- # GC.start
+ GC.enable
+ GC.start
- # bm.report("#clear ") do
- # person.preferences.clear
- # end
+ bm.report("#clear ") do
+ person.preferences.clear
+ end
- # bm.report("#count ") do
- # person.preferences.count
- # end
+ bm.report("#count ") do
+ person.preferences.count
+ end
- # bm.report("#delete_all ") do
- # person.preferences.delete_all
- # end
+ bm.report("#delete_all ") do
+ person.preferences.delete_all
+ end
- # person.preferences.clear
- # GC.start
+ person.preferences.clear
+ GC.start
- # bm.report("#push (batch) ") do
- # [].tap do |preferences|
- # i.times do |n|
- # preferences << Preference.new(:name => "Preference #{n}")
- # end
- # person.preferences.push(preferences)
- # end
- # end
+ bm.report("#push (batch) ") do
+ [].tap do |preferences|
+ i.times do |n|
+ preferences << Preference.new(:name => "Preference #{n}")
+ end
+ person.preferences.push(preferences)
+ end
+ end
- # bm.report("#each ") do
- # person.preferences.each do |preference|
- # preference.name
- # end
- # end
+ bm.report("#each ") do
+ person.preferences.each do |preference|
+ preference.name
+ end
+ end
- # preference = person.preferences.last
+ preference = person.preferences.last
- # bm.report("#find ") do
- # person.preferences.find(preference.id)
- # end
+ bm.report("#find ") do
+ person.preferences.find(preference.id)
+ end
- # bm.report("#delete ") do
- # person.preferences.delete(preference)
- # end
+ bm.report("#delete ") do
+ person.preferences.delete(preference)
+ end
- # person.preferences.clear
- # GC.start
- # end
- # end
+ person.preferences.clear
+ GC.start
+ end
+ end
[ 1000, 10000].each do |i|
Please sign in to comment.
Something went wrong with that request. Please try again.