Пример #1
0
def enableProfiler(signum, config):
    """
    Enables the profiler on specified signal
    """
    try:
        # If the profiler is available on the system then enable it
        import gevent_profiler
        
        if config.has_key('summaryOutput'):
            gevent_profiler.set_summary_output(config['summaryOutput'])

        if config.has_key('statsOutput'):
            gevent_profiler.set_stats_output(config['statsOutput'])

        if config.has_key('traceOutput'):
            gevent_profiler.set_trace_output(config['traceOutput'])

        if config.has_key('printPercentage'):
            gevent_profiler.print_percentages(config['printPercentage'])

        if config.has_key('countTimeBlocking'):
            gevent_profiler.time_blocking(config['countTimeBlocking'])

        gevent_profiler.attach_on_signal(signum=signum, duration=config['duration'])
        logging.getLogger().info("The profiler is enabled and waiting on signal %s." % signum)

    except Exception as ex:
        logging.getLogger().warn("Failed enabling the profiler: %s" % ex)
Пример #2
0
def start_profiler(prefix, pcts=False):
    """
    Start the gevent-profiler, outputting to the passed prefix-stats and prefix-summary.txt.

    You must call stop_profiler at a later point. The profiler is not safe to run twice at once
    as it keeps global state internally.

    @param  prefix      The prefix to use when naming the output files.
    @param  pcts        Whether the profiler should add percentages as well.
    """
    gevent_profiler.set_stats_output('%s-stats.txt' % prefix)
    gevent_profiler.set_summary_output('%s-summary.txt' % prefix)
    gevent_profiler.print_percentages(pcts)

    gevent_profiler.set_trace_output(None)  #'%s-trace.txt' % prefix)   @TODO make optional
    gevent_profiler.attach()
Пример #3
0
def start_profiler(prefix, pcts=False):
    """
    Start the gevent-profiler, outputting to the passed prefix-stats and prefix-summary.txt.

    You must call stop_profiler at a later point. The profiler is not safe to run twice at once
    as it keeps global state internally.

    @param  prefix      The prefix to use when naming the output files.
    @param  pcts        Whether the profiler should add percentages as well.
    """
    gevent_profiler.set_stats_output('%s-stats.txt' % prefix)
    gevent_profiler.set_summary_output('%s-summary.txt' % prefix)
    gevent_profiler.print_percentages(pcts)

    gevent_profiler.set_trace_output(
        None)  #'%s-trace.txt' % prefix)   @TODO make optional
    gevent_profiler.attach()