Created
July 16, 2014 14:27
-
-
Save oivoodoo/54ff23bf5699b312604e to your computer and use it in GitHub Desktop.
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
it 'should work faster using ranges in threads on aggregate' do | |
Report1 = Class.new do | |
include Mongoid::Report | |
report 'example' do | |
attach_to Model do | |
group_by :day | |
column :field1 | |
end | |
end | |
end | |
Report2 = Class.new do | |
include Mongoid::Report | |
report 'example' do | |
attach_to Model do | |
group_by :day | |
perform_using groups: 5, by: :day | |
column :field1 | |
end | |
end | |
end | |
5.times do |i| | |
10000.times { klass.create!(day: i.days.ago, field1: 1) } | |
end | |
time1 = Benchmark.measure do | |
rows = scoped.ranges(day: (0.days.ago..5.days.from_now)).all | |
end | |
time2 = Benchmark.measure do | |
rows = scoped.all | |
end | |
puts time2 | |
puts time1 | |
time2.real.should > time1.real | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment