def create_stats(self):
     """
         Stop collecting profile data and load them into
         a Stats object (which is returned).
     """
     _profile.stop()
     self._profile = Stats(_profile.data,1)
     return self._profile
def runctx(cmd,globals=None,locals=None,nruns=200):
    """
        Runs the command @cmd with with the given @globlas and @locals
        and collects profile data. The command is run @nruns (200 by default) and
        the data is averaged over these runs. Returns
        a Stats object with the collected data.
    """
    _locals = locals or {}
    _globals = globals or {}
    _profile.start()
    _profile.run(cmd,_globals,_locals,nruns)
    _profile.stop()
    return Stats(_profile.data,nruns)
 def runctx(self,cmd,globals,locals,nruns=200):
     """
         Runs the command @cmd with the given @globlas and @locals
         and collects profile data. The command is run @ntimes (200 by default) and
         the data is averaged over these runs.
     """
     _profile.stop()
     _profile.clear()
     _profile.start()
     for i in range(nruns):
         _profile.run(cmd,globals=globals,locals=locals)
     _profile.stop()
     self._profile = Stats(_profile.data,nruns)
 def runcall(self,func,ntimes,*args,**kwargs):
     """
         Calls the function @func with arguments @args, @kwargs
         and collects profile data. The function is called @ntimes
         and the data is averaged over these runs.
     """
     _profile.stop()
     _profile.clear()
     _profile.start()
     for i in range(ntimes):
         ret=func(*args,**kwargs)
     _profile.stop()
     self._profile = Stats(_profile.data,ntimes)
     return self._profile