static int profiler_init(ProfilerObject *pObj, PyObject *args, PyObject *kw) { PyObject *o; PyObject *timer = NULL; double timeunit = 0.0; int subcalls = 1; #ifdef PyTrace_C_CALL int builtins = 1; #else int builtins = 0; #endif static char *kwlist[] = {"timer", "timeunit", "subcalls", "builtins", 0}; if (!PyArg_ParseTupleAndKeywords(args, kw, "|Odii:Profiler", kwlist, &timer, &timeunit, &subcalls, &builtins)) return -1; if (setSubcalls(pObj, subcalls) < 0 || setBuiltins(pObj, builtins) < 0) return -1; o = pObj->externalTimer; pObj->externalTimer = timer; Py_XINCREF(timer); Py_XDECREF(o); pObj->externalTimerUnit = timeunit; return 0; }
static PyObject* profiler_enable(ProfilerObject *self, PyObject *args, PyObject *kwds) { int subcalls = -1; int builtins = -1; static char *kwlist[] = {"subcalls", "builtins", 0}; if (!PyArg_ParseTupleAndKeywords(args, kwds, "|ii:enable", kwlist, &subcalls, &builtins)) return NULL; if (setSubcalls(self, subcalls) < 0 || setBuiltins(self, builtins) < 0) return NULL; PyEval_SetProfile(profiler_callback, (PyObject*)self); self->flags |= POF_ENABLED; Py_INCREF(Py_None); return Py_None; }
static int profiler_init(ProfilerObject *pObj, PyObject *args, PyObject *kw) { PyObject *timer = NULL; double timeunit = 0.0; int subcalls = 1; int builtins = 1; static char *kwlist[] = {"timer", "timeunit", "subcalls", "builtins", 0}; if (!PyArg_ParseTupleAndKeywords(args, kw, "|Odii:Profiler", kwlist, &timer, &timeunit, &subcalls, &builtins)) return -1; if (setSubcalls(pObj, subcalls) < 0 || setBuiltins(pObj, builtins) < 0) return -1; pObj->externalTimerUnit = timeunit; Py_XINCREF(timer); Py_SETREF(pObj->externalTimer, timer); return 0; }