It seems more likely that it's the changing of the appearance that is taking a long time. Try your routine with a lock screen and unlock screen either side of the repeat loop.