Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Recur.getDates() is very slow since #488 #506

Closed
db82407 opened this issue Jul 14, 2021 · 0 comments
Closed

Recur.getDates() is very slow since #488 #506

db82407 opened this issue Jul 14, 2021 · 0 comments
Assignees

Comments

@db82407
Copy link
Contributor

db82407 commented Jul 14, 2021

Describe the bug

Recur.getDates() has become very slow since #488, when the seed date has a timezone set.

To Reproduce

I've added a new test-case to RecurTest to demonstrate the problem in PR #507

    private static TimeZoneRegistry tzReg = TimeZoneRegistryFactory.getInstance().createRegistry();

    public RecurTest(Recur recur, Date seed, Date periodStart, Date periodEnd, Value value, int expectedCount, long maxTime) {
        this("testGetDatesMaxTime", recur, seed, periodStart, periodEnd, value);
        this.expectedCount = expectedCount;
        this.maxTime = maxTime;
    }

    public void testGetDatesMaxTime() {
        DateTime start = new DateTime(seed);
        start.setTimeZone(tzReg.getTimeZone("Europe/London"));
        Period period = new Period(new DateTime(periodStart), new DateTime(periodEnd));

        long t0 = System.currentTimeMillis();
        DateList dates = recur.getDates(start, period, value);
        long dt = System.currentTimeMillis() - t0;

        String message = String.format("maxTime exceeded %dms", maxTime);
        assertEquals(message, maxTime, Math.max(dt, maxTime));
        assertEquals(expectedCount, dates.size());
    }

    // check maxTime
    recur = new Recur("FREQ=WEEKLY;WKST=MO;UNTIL=20160901T230000;INTERVAL=1;BYDAY=TH");
    suite.addTest(new RecurTest(recur, new DateTime("20160414T100000"),
            new DateTime("20110713T213021"), new DateTime("20230713T213021"),
            Value.DATE_TIME, 21, 100));

Expected behavior

Recur.getDates() should complete in < 100ms.

Before #488 it typically took < 10ms

Screenshots

After #488 it now takes > 900ms!
junit.framework.AssertionFailedError: maxTime exceeded 100ms expected:<100> but was:<909>

Environment (please complete the following information):

  • OS: Linux
  • Java Version [8, 11]

Additional context

This test fails to demonstrate the problem.
PR #508 fixes this issue and when applied the test succeeds,

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants