home *** CD-ROM | disk | FTP | other *** search
/ Chip 2004 December / CHIP_CD_2004-12.iso / bonus / oo / OOo_1.1.3_ru_RU_infra_WinIntel_install.exe / $PLUGINSDIR / f_0372 / python-core-2.2.2 / lib / hotshot / __init__.py next >
Text File  |  2004-10-09  |  1KB  |  42 lines

  1. """High-perfomance logging profiler, mostly written in C."""
  2.  
  3. import _hotshot
  4.  
  5. from _hotshot import ProfilerError
  6.  
  7.  
  8. class Profile:
  9.     def __init__(self, logfn, lineevents=0, linetimings=1):
  10.         self.lineevents = lineevents and 1 or 0
  11.         self.linetimings = (linetimings and lineevents) and 1 or 0
  12.         self._prof = p = _hotshot.profiler(
  13.             logfn, self.lineevents, self.linetimings)
  14.  
  15.     def close(self):
  16.         self._prof.close()
  17.  
  18.     def start(self):
  19.         self._prof.start()
  20.  
  21.     def stop(self):
  22.         self._prof.stop()
  23.  
  24.     def addinfo(self, key, value):
  25.         self._prof.addinfo(key, value)
  26.  
  27.     # These methods offer the same interface as the profile.Profile class,
  28.     # but delegate most of the work to the C implementation underneath.
  29.  
  30.     def run(self, cmd):
  31.         import __main__
  32.         dict = __main__.__dict__
  33.         return self.runctx(cmd, dict, dict)
  34.  
  35.     def runctx(self, cmd, globals, locals):
  36.         code = compile(cmd, "<string>", "exec")
  37.         self._prof.runcode(code, globals, locals)
  38.         return self
  39.  
  40.     def runcall(self, func, *args, **kw):
  41.         return self._prof.runcall(func, args, kw)
  42.