Rewrite perftest to use a Python loop rather than 'yield from'