#summary yappi Usage Manual
= Reference Manual =
----
*Latest version: 0.62*
yappi.start(builtins=False)
_Remarks:_
Starts profiling all threads in the current interpreter instance. This function can be called from any thread at any time. Note that yappi is per-interpreter resource, you cannot run more than one instance per-interpreter. A relevant exception will be raised if you do so.
Resumes previous profiling data if stop() is called previously.(Note: you can clear the profiling stats via clear_stats() between a successfull start()/stop() sequence.)
_Params:_
Function will take an optional parameter named *builtins*. As the name suggests, this means we also want to profile builtin functions used by standart Python modules. It is _False_ by _default_.
----
yappi.stop()
_Remarks:_
Stops the currently running yappi instance. Same profiling session might be resumed later by calling start().(unless clear_stats() is called in that period.)
----
yappi.enum_stats(fenum)
_Remarks:_
Enumerates the profile stats one by one. The parameter _fenum_ should be a callable Python function with one parameter, say _stat_entry_ which will be invoked for every profiled function. The parameter is a Python tuple instance consisting all of the information related to function profiling: ('function_name', 'callcount', 'ttot', 'tsub')
_Example:_
{{{
> def foo(): pass
import yappi
yappi.start()
foo()
def estat(stat_entry):
print stat_entry
yappi.enum_stats(estat)
>>>('tt.py.foo:4', 1, 0.40625, 0.28125)
}}}
----
yappi.enum_thread_stats()
_Remarks:_
Enumerates the profile stats one by one. The parameter _fenum_ should be a callable Python function with one parameter, say _stat_entry_ which will be invoked for every profiled function. The parameter is a Python tuple instance consisting all of the information related to thread profiling: ('thread_name', 'thread_id', 'last_func', 'ttot', 'sched_count')
----
yappi.get_stats(sorttype, sortorder, limit)
_Remarks:_
Returns a YStats object. YStats object will have two list attributes(func_stats, thread_stats). See the example below for the usage.
_Params:_
* sorttype: There are several columns in the statistics results. This parameter controls on which column you want the sort to be based on. The valid values for this parameter are:
* yappi.SORTTYPE_NAME : Sorts the results according to function name.
* yappi.SORTTYPE_NCALL : Sorts the results according to their call count._(default)_
* yappi.SORTTYPE_TTOTAL: Sorts the results according to their total time.
* yappi.SORTTYPE_TSUB : Sorts the results according to their total subtime. Subtime means the total spent time in the function minus the total time spent in the other functions called from this function.
* yappi.SORTTYPE_TAVG : Sorts the results according to their total average time.
* sortorder: The order type of the column. Valid values for this parameter are:
* yappi.SORTORDER_ASCENDING : Sorts the values in ascending order.
* yappi.SORTORDER_DESCENDING : Sorts the values in descending order._(default)_
* limit: There may be too many functions profiled and user is not interested in many of them. So, limit gives the user the ability to limit the result set returned by the function. With this and above param, a user easily retrieves the top running functions that he/she is interested in.
* yappi.SHOW_ALL : Returns all of the statistic results._(default)_
* thread_stats_on: If set to true, returns thread profiling information. True by _default_.
_Example:_
{{{
'''
TODO://
'''
}}}
----
yappi.print_stats()
_Remarks:_
Prints the current statistic results to the stdout. The parameters are same as the get_stats() function.
----
yappi.clear_stats()
_Remarks:_
Clears the profiler results. Note that the only way to really delete the statistics is this function. The results stays with the application unless application(all threads including the main thread) exists or clear_stats() is called. yappi does not mess with the result set upon stop() or start(). It is user's responsibility to clear the statistics whenever appropiate. This also means without calling clear_stats(), you can resume previously stopped profile informations via start().
----
yappi.is_running()
_Remarks:_
Returns a boolean indicating whether yappi is running or not.