'Run reactor under the standard profiler.'

def run(self, reactor):

    try:
        import profile
    except ImportError as e:
        self._reportImportError('profile', e)
    p = profile.Profile()
    p.runcall(reactor.run)
    if self.saveStats:
        p.dump_stats(self.profileOutput)
    else:
        (tmp, sys.stdout) = (sys.stdout, open(self.profileOutput, 'a'))
        try:
            p.print_stats()
        finally:
            (sys.stdout, tmp) = (tmp, sys.stdout)
            tmp.close()
