16
16
int uwsgi_python_profiler_call(PyObject *obj, PyFrameObject *frame, int what, PyObject *arg) {
19
static uint64_t last_ts = 0;
20
uint64_t now = uwsgi_micros();
21
uwsgi_log("[uWSGI Python profiler] CALL: %s (line %d) -> %s %d args, stacksize %d\n",
25
if (last_ts == 0) delta = 0;
26
else delta = now - last_ts;
28
uwsgi_log("[uWSGI Python profiler %llu] CALL: %s (line %d) -> %s %d args, stacksize %d\n",
29
(unsigned long long) delta,
22
30
PyString_AsString(frame->f_code->co_filename),
23
31
PyFrame_GetLineNumber(frame),
24
32
PyString_AsString(frame->f_code->co_name), frame->f_code->co_argcount, frame->f_code->co_stacksize);
26
34
case PyTrace_C_CALL:
27
uwsgi_log("[uWSGI Python profiler] C CALL: %s (line %d) -> %s %d args, stacksize %d\n",
35
if (last_ts == 0) delta = 0;
36
else delta = now - last_ts;
38
uwsgi_log("[uWSGI Python profiler %llu] C CALL: %s (line %d) -> %s %d args, stacksize %d\n",
39
(unsigned long long) delta,
28
40
PyString_AsString(frame->f_code->co_filename),
29
41
PyFrame_GetLineNumber(frame),
30
42
PyEval_GetFuncName(arg), frame->f_code->co_argcount, frame->f_code->co_stacksize);
50
int uwsgi_python_tracer(PyObject *obj, PyFrameObject *frame, int what, PyObject *arg) {
53
static uint64_t last_ts = 0;
54
uint64_t now = uwsgi_micros();
57
if (what == PyTrace_LINE) {
62
delta = now - last_ts;
65
uwsgi_log("[uWSGI Python profiler %llu] file %s line %d: %s argc:%d\n", (unsigned long long)delta, PyString_AsString(frame->f_code->co_filename), PyFrame_GetLineNumber(frame), PyString_AsString(frame->f_code->co_name), frame->f_code->co_argcount);