cpython/Modules/_lsprof.c

#ifndef Py_BUILD_CORE_BUILTIN
#define Py_BUILD_CORE_MODULE
#endif

#include "Python.h"
#include "pycore_call.h"          // _PyObject_CallNoArgs()
#include "pycore_ceval.h"         // _PyEval_SetProfile()
#include "pycore_pystate.h"       // _PyThreadState_GET()
#include "pycore_time.h"          // _PyTime_FromLong()

#include "rotatingtree.h"

/************************************************************/
/* Written by Brett Rosen and Ted Czotter */

struct _ProfilerEntry;

/* represents a function called from another function */
ProfilerSubEntry;

/* represents a function or user defined block */
ProfilerEntry;

ProfilerContext;

ProfilerObject;

#define POF_ENABLED
#define POF_SUBCALLS
#define POF_BUILTINS
#define POF_EXT_TIMER
#define POF_NOMEMORY

/*[clinic input]
module _lsprof
class _lsprof.Profiler "ProfilerObject *" "&ProfilerType"
[clinic start generated code]*/
/*[clinic end generated code: output=da39a3ee5e6b4b0d input=e349ac952152f336]*/

#include "clinic/_lsprof.c.h"

_lsprof_state;

static inline _lsprof_state*
_lsprof_get_state(PyObject *module)
{}

/*** External Timers ***/

static PyTime_t CallExternalTimer(ProfilerObject *pObj)
{}

static inline PyTime_t
call_timer(ProfilerObject *pObj)
{}


/*** ProfilerObject ***/

static PyObject *
normalizeUserObj(PyObject *obj)
{}

static ProfilerEntry*
newProfilerEntry(ProfilerObject *pObj, void *key, PyObject *userObj)
{}

static ProfilerEntry*
getEntry(ProfilerObject *pObj, void *key)
{}

static ProfilerSubEntry *
getSubEntry(ProfilerObject *pObj, ProfilerEntry *caller, ProfilerEntry* entry)
{}

static ProfilerSubEntry *
newSubEntry(ProfilerObject *pObj,  ProfilerEntry *caller, ProfilerEntry* entry)
{}

static int freeSubEntry(rotating_node_t *header, void *arg)
{}

static int freeEntry(rotating_node_t *header, void *arg)
{}

static void clearEntries(ProfilerObject *pObj)
{}

static void
initContext(ProfilerObject *pObj, ProfilerContext *self, ProfilerEntry *entry)
{}

static void
Stop(ProfilerObject *pObj, ProfilerContext *self, ProfilerEntry *entry)
{}

static void
ptrace_enter_call(PyObject *self, void *key, PyObject *userObj)
{}

static void
ptrace_leave_call(PyObject *self, void *key)
{}

static int
pending_exception(ProfilerObject *pObj)
{}

/************************************************************/

static PyStructSequence_Field profiler_entry_fields[] =;

static PyStructSequence_Field profiler_subentry_fields[] =;

static PyStructSequence_Desc profiler_entry_desc =;

static PyStructSequence_Desc profiler_subentry_desc =;

statscollector_t;

static int statsForSubEntry(rotating_node_t *node, void *arg)
{}

static int statsForEntry(rotating_node_t *node, void *arg)
{}

/*[clinic input]
_lsprof.Profiler.getstats

    cls: defining_class

list of profiler_entry objects.

getstats() -> list of profiler_entry objects

Return all information collected by the profiler.
Each profiler_entry is a tuple-like object with the
following attributes:

    code          code object
    callcount     how many times this was called
    reccallcount  how many times called recursively
    totaltime     total time in this entry
    inlinetime    inline time in this entry (not in subcalls)
    calls         details of the calls

The calls attribute is either None or a list of
profiler_subentry objects:

    code          called code object
    callcount     how many times this is called
    reccallcount  how many times this is called recursively
    totaltime     total time spent in this call
    inlinetime    inline time (not in further subcalls)
[clinic start generated code]*/

static PyObject *
_lsprof_Profiler_getstats_impl(ProfilerObject *self, PyTypeObject *cls)
/*[clinic end generated code: output=1806ef720019ee03 input=445e193ef4522902]*/
{}

static int
setSubcalls(ProfilerObject *pObj, int nvalue)
{}

static int
setBuiltins(ProfilerObject *pObj, int nvalue)
{}

PyObject* pystart_callback(ProfilerObject* self, PyObject *const *args, Py_ssize_t size)
{}

PyObject* pyreturn_callback(ProfilerObject* self, PyObject *const *args, Py_ssize_t size)
{}

PyObject* get_cfunc_from_callable(PyObject* callable, PyObject* self_arg, PyObject* missing)
{}

PyObject* ccall_callback(ProfilerObject* self, PyObject *const *args, Py_ssize_t size)
{}

PyObject* creturn_callback(ProfilerObject* self, PyObject *const *args, Py_ssize_t size)
{}

static const struct {} callback_table[] =;

PyDoc_STRVAR(enable_doc, "\
enable(subcalls=True, builtins=True)\n\
\n\
Start collecting profiling information.\n\
If 'subcalls' is True, also records for each function\n\
statistics separated according to its current caller.\n\
If 'builtins' is True, records the time spent in\n\
built-in functions separately from their caller.\n\
");

static PyObject*
profiler_enable(ProfilerObject *self, PyObject *args, PyObject *kwds)
{}

static void
flush_unmatched(ProfilerObject *pObj)
{}

PyDoc_STRVAR(disable_doc, "\
disable()\n\
\n\
Stop collecting profiling information.\n\
");

static PyObject*
profiler_disable(ProfilerObject *self, PyObject* noarg)
{}

PyDoc_STRVAR(clear_doc, "\
clear()\n\
\n\
Clear all profiling information collected so far.\n\
");

static PyObject*
profiler_clear(ProfilerObject *pObj, PyObject* noarg)
{}

static int
profiler_traverse(ProfilerObject *op, visitproc visit, void *arg)
{}

static void
profiler_dealloc(ProfilerObject *op)
{}

static int
profiler_init(ProfilerObject *pObj, PyObject *args, PyObject *kw)
{}

static PyMethodDef profiler_methods[] =;

PyDoc_STRVAR(profiler_doc, "\
Profiler(timer=None, timeunit=None, subcalls=True, builtins=True)\n\
\n\
    Builds a profiler object using the specified timer function.\n\
    The default timer is a fast built-in one based on real time.\n\
    For custom timer functions returning integers, timeunit can\n\
    be a float specifying a scale (i.e. how long each integer unit\n\
    is, in seconds).\n\
");

static PyType_Slot _lsprof_profiler_type_spec_slots[] =;

static PyType_Spec _lsprof_profiler_type_spec =;

static PyMethodDef moduleMethods[] =;

static int
_lsprof_traverse(PyObject *module, visitproc visit, void *arg)
{}

static int
_lsprof_clear(PyObject *module)
{}

static void
_lsprof_free(void *module)
{}

static int
_lsprof_exec(PyObject *module)
{}

static PyModuleDef_Slot _lsprofslots[] =;

static struct PyModuleDef _lsprofmodule =;

PyMODINIT_FUNC
PyInit__lsprof(void)
{}