Quick benchmark to see how ice_cube behaves in the far future. It seems that the cost is linearly increasing.
Results at: http://bit.ly/pjsQH1
(note: second version is without the time parse in the loop)
Quick benchmark to see how ice_cube behaves in the far future. It seems that the cost is linearly increasing.
Results at: http://bit.ly/pjsQH1
(note: second version is without the time parse in the loop)
| require 'spec_helper' | |
| include IceCube | |
| describe "Recurrence" do | |
| describe 'repeat monthly on day of the month' do | |
| let(:schedule) { | |
| start_date = Time.parse('2011-5-14') | |
| day_of_month = start_date.day # day of month | |
| schedule = Schedule.new(start_date) | |
| schedule.add_recurrence_rule Rule.monthly.day_of_month(day_of_month) | |
| schedule | |
| } | |
| it 'is fast enough even in the far future' do | |
| (2012..2050).each do |year| | |
| start_time = Time.parse("#{year}-5-5") | |
| end_time = Time.parse("#{year+1}-5-5") | |
| measure = Benchmark.realtime { | |
| 300.times do | |
| occurrences = schedule.occurrences_between( | |
| start_time, | |
| end_time | |
| ) | |
| end | |
| } | |
| puts "#{year} => #{measure}" | |
| end | |
| end | |
| end |