How to use the pprofile.ProfileRunnerBase function in pprofile

To help you get started, we’ve selected a few pprofile examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github vpelletier / pprofile / pprofile.py View on Github external
>>>    # Code to profile
        Is equivalent to:
        >>> s_profile = StatisticProfile()
        >>> s_thread = StatisticThread(profiler=s_profile, single=False)
        >>> with s_thread:
        >>>    # Code to profile
        """
        return StatisticThread(
            profiler=self, period=period, single=single, group=group,
            name=name,
        )

# BBB
StatisticalProfile = StatisticProfile

class StatisticThread(threading.Thread, ProfileRunnerBase):
    """
    Usage in a nutshell:
      with StatisticThread() as profiler_thread:
        # do stuff
      profiler_thread.profiler.print_stats()
    """
    __slots__ = (
        '_test',
        '_start_time',
        'clean_exit',
    )

    def __init__(self, profiler=None, period=.001, single=True, group=None, name=None):
        """
        profiler (None or StatisticProfile instance)
          Available on instances as the "profiler" read-only property.