Skip to content

Instantly share code, notes, and snippets.

@thbar
Created September 15, 2011 13:25
Show Gist options
  • Save thbar/1219213 to your computer and use it in GitHub Desktop.
Save thbar/1219213 to your computer and use it in GitHub Desktop.
A quick benchmark for ice_cube

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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment