Class _profiler
object --+
|
_profiler
The profiler object.
This object manages profiling in the system.
Typically, you enable profiling with the start method, and stop it with
the stop method. The profile data can be found in the charges
and call_counts instance variables.
The profiler tracks aggregate and non-aggregate time (aggregate being time
spent in the function plus all the functions it calls). It also tracks how
many times a function is called, and how many times it makes a call to a
particular function.
The bench and call_counts_object docstrings describe a little bit about
how the profiler works. (An important element to understand is that the
global "counter" bench object is unique and is different than other bench
objects, and is the baseline from which all values are computed.)
For each coroutine, there is a linked-list of the call stack for that
coroutine (a call_stack structure assigned to the top value of the
coroutine). Each element on the call stack has a seperate bench object
that is used for tracking time spent in that function at that level of the
call stack for that coroutine.
There is a global "charges" dictionary which tracks time spent in each
function in the program.
When calling a new function, the time spent in the previous function (as
accumulated in the "counter") is added to its bench object on the call
stack. A new bench object is then created and pushed onto the call stack.
When returning from a function, the bench object from the call stack is
added to the global "charges" dictionary for that function, as well as
updating call counts. Additionally, the caller's bench object from the
call stack has the aggregate time from the callee added to it.
When yielding, the time spent so-far is added to the top of the call stack
of the current coroutine (and thus resets the "counter" object to start the
timer for the next coroutine to be resumed).
|
__init__(...)
x.__init__(...) initializes x; see help(type(x)) for signature |
|
|
a new object with type S, a subtype of T
|
|
|
start(...)
Start the profiler. |
|
|
|
stop(...)
Stop the profiler. |
|
|
Inherited from object :
__delattr__ ,
__format__ ,
__getattribute__ ,
__hash__ ,
__reduce__ ,
__reduce_ex__ ,
__repr__ ,
__setattr__ ,
__sizeof__ ,
__str__ ,
__subclasshook__
|
|
bench_class
: The bench class object the user passed in to indicate
the type of benchmarking to perform.
|
|
call_counts
: A dictionary of call counts.
|
|
charges
: The profile data as a dictionary.
|
|
counter
: The base bench class instance that is used to provide a
baseline that all other bench instance deltas are computed from.
|
|
func_cache
: A cache of function objects.
|
|
main_bench
: Bench instance tracking the time spent in the main
thread (the scheduler).
|
|
start_ticks
: TSC value when profiling started.
|
|
wait_bench
: Bench instance tracking the time spent waiting in the
poller (kqueue).
|
Inherited from object :
__class__
|
__init__(...)
(Constructor)
|
|
x.__init__(...) initializes x; see help(type(x)) for signature
- Overrides:
object.__init__
|
- Returns: a new object with type S, a subtype of T
- Overrides:
object.__new__
|
Stop the profiler.
- Returns:
- Returns the total TSC ticks spent during the profile session.
|
call_counts
: A dictionary of call counts. The key is the caller
function object. The value is a call_counts_object which is
essentially an array of callees (as function objects) and the
number of times the function has called each of those callees.
|
charges
: The profile data as a dictionary. The key is a function
object, the value is a bench instance.
|
func_cache
: A cache of function objects. The key is a pointer to
the actual code object (or the C pointer for C functions) and the
value is a function object.
|