I know you're only printing out every 1000, but any print statements at all can have a surprising effect on performance.