From 39d84c3cda7e5839cd14a4243716f2942c08eef1 Mon Sep 17 00:00:00 2001 From: Akita Noek Date: Mon, 25 Jan 2016 09:37:59 -0500 Subject: [PATCH] 5% performance boost on make test Calling `.after` on a dateutil.rrule object that has an UNTIL clause performs very poorly if the interval is low and the start time is a long time ago. This patch replaces two test cases where we were using a minute interval with a fixed start time of (currently) 2 years ago, which resulted in aproximately 40s of execution time to simply evaluate `.after(now())`. Replacing these two tests with tests that start from "yesterday" while keeping the same INTERVAL and UNTIL settings eliminates this unnecessary slowdown while maintaining the spirit of the original tests. --- awx/main/tests/schedules.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/awx/main/tests/schedules.py b/awx/main/tests/schedules.py index a0ac11bb68..4a4a0bcee3 100644 --- a/awx/main/tests/schedules.py +++ b/awx/main/tests/schedules.py @@ -14,12 +14,13 @@ from awx.main.tests.base import BaseTest __all__ = ['ScheduleTest'] -UNTIL_SCHEDULE = "DTSTART:20140331T075000Z RRULE:FREQ=MINUTELY;INTERVAL=1;UNTIL=30230401T075000Z" +YESTERDAY = (datetime.date.today() - datetime.timedelta(1)).strftime('%Y%m%dT075000Z') +UNTIL_SCHEDULE = "DTSTART:%s RRULE:FREQ=MINUTELY;INTERVAL=1;UNTIL=30230401T075000Z" % YESTERDAY EXPIRED_SCHEDULES = ["DTSTART:19340331T055000Z RRULE:FREQ=MINUTELY;INTERVAL=10;COUNT=5"] INFINITE_SCHEDULES = ["DTSTART:30340331T055000Z RRULE:FREQ=MINUTELY;INTERVAL=10"] GOOD_SCHEDULES = ["DTSTART:20500331T055000Z RRULE:FREQ=MINUTELY;INTERVAL=10;COUNT=5", "DTSTART:20240331T075000Z RRULE:FREQ=DAILY;INTERVAL=1;COUNT=1", - "DTSTART:20140331T075000Z RRULE:FREQ=MINUTELY;INTERVAL=1;UNTIL=20230401T075000Z", + "DTSTART:%s RRULE:FREQ=MINUTELY;INTERVAL=1;UNTIL=20230401T075000Z" % YESTERDAY, "DTSTART:20140331T075000Z RRULE:FREQ=WEEKLY;INTERVAL=1;BYDAY=MO,WE,FR", "DTSTART:20140331T075000Z RRULE:FREQ=WEEKLY;INTERVAL=5;BYDAY=MO", "DTSTART:20140331T075000Z RRULE:FREQ=MONTHLY;INTERVAL=1;BYMONTHDAY=6",