Esempio n. 1
0
    def get(self):
        _yappi._pause()
        self.clear()
        try:
            _yappi.enum_func_stats(self._enumerator)

            # convert the children info from tuple to YChildFuncStat
            for stat in self:
                _childs = YChildFuncStats()
                for child_tpl in stat.children:
                    rstat = self[child_tpl[0]]

                    # sometimes even the profile results does not contain the result because of filtering
                    # or timing(call_leave called but call_enter is not), with this we ensure that the children
                    # index always point to a valid stat.
                    if rstat is None:
                        continue

                    tavg = rstat.ttot / rstat.ncall
                    cfstat = YChildFuncStat(child_tpl + (
                        tavg,
                        rstat.builtin,
                        rstat.full_name,
                        rstat.module,
                        rstat.lineno,
                        rstat.name,
                    ))
                    _childs.append(cfstat)
                stat.children = _childs
            result = super(YFuncStats, self).get()
        finally:
            _yappi._resume()
        return result
Esempio n. 2
0
    def get(self, filter=None):
        _yappi._pause()
        self.clear()
        try:
            self._filter = filter
            _yappi.enum_func_stats(self._enumerator)
            self._filter = None

            # convert the children info from tuple to YChildFuncStat
            for stat in self:

                _childs = YChildFuncStats()
                for child_tpl in stat.children:
                    rstat = self[child_tpl[0]]

                    # sometimes even the profile results does not contain the result because of filtering
                    # or timing(call_leave called but call_enter is not), with this we ensure that the children
                    # index always point to a valid stat.
                    if rstat is None:
                        continue

                    tavg = rstat.ttot / rstat.ncall
                    cfstat = YChildFuncStat(
                        child_tpl + (tavg, rstat.builtin, rstat.full_name, rstat.module, rstat.lineno, rstat.name)
                    )
                    _childs.append(cfstat)
                stat.children = _childs
            result = super(YFuncStats, self).get()
        finally:
            _yappi._resume()
        return result
Esempio n. 3
0
def clear_stats():
    """
    Clears all of the profile results.
    """
    _yappi._pause()
    try:
        _yappi.clear_stats()
    finally:
        _yappi._resume()
Esempio n. 4
0
 def get(self):
     _yappi._pause()
     self.clear()
     try:
         _yappi.enum_thread_stats(self._enumerator)
         result = super(YThreadStats, self).get()
     finally:
         _yappi._resume()
     return result
Esempio n. 5
0
def clear_stats():
    """
    Clears all of the profile results.
    """
    _yappi._pause()
    try:
        _yappi.clear_stats()
    finally:
        _yappi._resume()
Esempio n. 6
0
 def get(self):
     _yappi._pause()
     self.clear()
     try:
         _yappi.enum_thread_stats(self._enumerator)
         result = super(YThreadStats, self).get()
     finally:
         _yappi._resume()
     return result
Esempio n. 7
0
def get_thread_stats():
    """
    Gets the thread profiler results with given filters and returns an iterable.
    """
    _yappi._pause()
    try:
        stats = YThreadStats().get()
    finally:
        _yappi._resume()
    return stats
Esempio n. 8
0
def get_thread_stats():
    """
    Gets the thread profiler results with given filters and returns an iterable.
    """
    _yappi._pause()
    try:
        stats = YThreadStats().get()
    finally:
        _yappi._resume()
    return stats
Esempio n. 9
0
def get_func_stats():
    """
    Gets the function profiler results with given filters and returns an iterable.
    """
    # multiple invocation pause/resume is allowed. This is needed because
    # not only get() is executed here.
    _yappi._pause()
    try:
        stats = YFuncStats().get()
    finally:
        _yappi._resume()
    return stats
Esempio n. 10
0
def get_func_stats(filter=None):
    """
    Gets the function profiler results with given filters and returns an iterable.
    """
    # multiple invocation pause/resume is allowed. This is needed because
    # not only get() is executed here.
    _yappi._pause()
    try:
        stats = YFuncStats().get(filter=filter)
    finally:
        _yappi._resume()
    return stats