#ifndef Py_BUILD_CORE_BUILTIN
#define Py_BUILD_CORE_MODULE …
#endif
#include "Python.h"
#include "pycore_call.h"
#include "pycore_ceval.h"
#include "pycore_pystate.h"
#include "pycore_time.h"
#include "rotatingtree.h"
struct _ProfilerEntry;
ProfilerSubEntry;
ProfilerEntry;
ProfilerContext;
ProfilerObject;
#define POF_ENABLED …
#define POF_SUBCALLS …
#define POF_BUILTINS …
#define POF_EXT_TIMER …
#define POF_NOMEMORY …
#include "clinic/_lsprof.c.h"
_lsprof_state;
static inline _lsprof_state*
_lsprof_get_state(PyObject *module)
{ … }
static PyTime_t CallExternalTimer(ProfilerObject *pObj)
{ … }
static inline PyTime_t
call_timer(ProfilerObject *pObj)
{ … }
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)
{ … }
static PyObject *
_lsprof_Profiler_getstats_impl(ProfilerObject *self, PyTypeObject *cls)
{ … }
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)
{ … }