-
Notifications
You must be signed in to change notification settings - Fork 4
Open
Labels
Description
It looks like the iteration is always starting at dtstart instead of the start value passed to .between(), which makes it take a lot longer in correlation to the dtstart value.
In the example you can see that it already starts getting slow fairly quickly. For 2001 it takes about 100ms, for 2012 already one second, and by 2030 you are at 2-3 seconds.
import { DateTime, Frequency, RRule, RRuleSet } from 'rrule-rust';
let start = DateTime.utc(2000, 1, 1, 0, 0, 0);
let until = start;
const set = new RRuleSet({
dtstart: start,
rrules: [new RRule({ frequency: Frequency.Minutely })],
tzid: 'UTC',
});
for (let year = 2000; year < 3000; year++) {
start = until;
until = DateTime.fromObject({ ...start.toObject(), year });
const now = Date.now();
const dates = set.between(start, until, false);
const elapsed = Date.now() - now;
console.log(`found ${dates.length} dates in year ${year}, took ${elapsed}ms`);
}