Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

no need to include Mongoid::EagerLoading

  • Loading branch information...
commit 24b33265013bd76ab73a500f3ad3ba275610ded7 1 parent 3026e4b
@flyerhzm authored
Showing with 8 additions and 10 deletions.
  1. +8 −9 benchmark/benchmark.rb
  2. +0 −1  spec/models/person.rb
View
17 benchmark/benchmark.rb
@@ -8,8 +8,8 @@
config.master = Mongo::Connection.new.db("mongoid_perf_test", :logger => Logger.new($stdout, :info))
end
-# Mongoid.master.collection("people").drop
-# Mongoid.master.collection("posts").drop
+Mongoid.master.collection("people").drop
+Mongoid.master.collection("posts").drop
class Person
include Mongoid::Document
@@ -21,16 +21,15 @@ class Person
class Post
include Mongoid::Document
include Mongoid::Timestamps
- include Mongoid::EagerLoading
field :title
referenced_in :person
end
-# 10000.times do |n|
-# person = Person.create(:name => "Test_#{n}")
-# person.posts.create(:title => "Test_#{2*n}")
-# person.posts.create(:title => "Test_#{2*n+1}")
-# end
+10000.times do |n|
+ person = Person.create(:name => "Test_#{n}")
+ person.posts.create(:title => "Test_#{2*n}")
+ person.posts.create(:title => "Test_#{2*n+1}")
+end
puts "Starting benchmark..."
Benchmark.bm(60) do |bm|
@@ -55,4 +54,4 @@ class Post
bm.report("Finding 100 posts with person, with eager loading") do
Post.limit(100).includes(:person).each { |p| p.person.name }
end
-end
+end
View
1  spec/models/person.rb
@@ -1,7 +1,6 @@
class Person
include Mongoid::Document
include Mongoid::Timestamps
- include Mongoid::EagerLoading
attr_accessor :mode
Please sign in to comment.
Something went wrong with that request. Please try again.