Esempio n. 1
0
# 2016.11.19 19:59:05 Støední Evropa (bìžný èas)
# Embedded file name: scripts/common/Lib/hotshot/__init__.py
"""High-perfomance logging profiler, mostly written in C."""
import _hotshot
from _hotshot import ProfilerError
from warnings import warnpy3k as _warnpy3k
_warnpy3k(
    "The 'hotshot' module is not supported in 3.x, use the 'profile' module instead.",
    stacklevel=2)


class Profile:
    def __init__(self, logfn, lineevents=0, linetimings=1):
        self.lineevents = lineevents and 1 or 0
        self.linetimings = linetimings and lineevents and 1 or 0
        self._prof = p = _hotshot.profiler(logfn, self.lineevents,
                                           self.linetimings)
        if self.__class__ is Profile:
            self.close = p.close
            self.start = p.start
            self.stop = p.stop
            self.addinfo = p.addinfo

    def close(self):
        """Close the logfile and terminate the profiler."""
        self._prof.close()

    def fileno(self):
        """Return the file descriptor of the profiler's log file."""
        return self._prof.fileno()
Esempio n. 2
0
# Embedded file name: scripts/common/Lib/hotshot/__init__.py
"""High-perfomance logging profiler, mostly written in C."""
import _hotshot
from _hotshot import ProfilerError
from warnings import warnpy3k as _warnpy3k

_warnpy3k("The 'hotshot' module is not supported in 3.x, use the 'profile' module instead.", stacklevel=2)


class Profile:
    def __init__(self, logfn, lineevents=0, linetimings=1):
        self.lineevents = lineevents and 1 or 0
        self.linetimings = linetimings and lineevents and 1 or 0
        self._prof = p = _hotshot.profiler(logfn, self.lineevents, self.linetimings)
        if self.__class__ is Profile:
            self.close = p.close
            self.start = p.start
            self.stop = p.stop
            self.addinfo = p.addinfo

    def close(self):
        """Close the logfile and terminate the profiler."""
        self._prof.close()

    def fileno(self):
        """Return the file descriptor of the profiler's log file."""
        return self._prof.fileno()

    def start(self):
        """Start the profiler."""
        self._prof.start()