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
def clear(self): """ Reset all profile counters (clear collected data) & stop collecting. """ _profile.clear()