mirror of
https://github.com/python/cpython.git
synced 2025-08-30 13:38:43 +00:00
bpo-46072: Add simple stats for Python calls. (GH-30989)
This commit is contained in:
parent
9a24127113
commit
90ab138bbd
4 changed files with 29 additions and 0 deletions
|
@ -1651,6 +1651,7 @@ PyObject* _Py_HOT_FUNCTION
|
|||
_PyEval_EvalFrameDefault(PyThreadState *tstate, InterpreterFrame *frame, int throwflag)
|
||||
{
|
||||
_Py_EnsureTstateNotNULL(tstate);
|
||||
CALL_STAT_INC(pyeval_calls);
|
||||
|
||||
#if USE_COMPUTED_GOTOS
|
||||
/* Import the static jump table */
|
||||
|
@ -2252,6 +2253,7 @@ handle_eval_breaker:
|
|||
_PyFrame_SetStackPointer(frame, stack_pointer);
|
||||
new_frame->previous = frame;
|
||||
frame = cframe.current_frame = new_frame;
|
||||
CALL_STAT_INC(inlined_py_calls);
|
||||
goto start_frame;
|
||||
}
|
||||
|
||||
|
@ -4589,6 +4591,7 @@ handle_eval_breaker:
|
|||
_PyFrame_SetStackPointer(frame, stack_pointer);
|
||||
new_frame->previous = frame;
|
||||
cframe.current_frame = frame = new_frame;
|
||||
CALL_STAT_INC(inlined_py_calls);
|
||||
goto start_frame;
|
||||
}
|
||||
/* Callable is not a normal Python function */
|
||||
|
@ -4705,6 +4708,7 @@ handle_eval_breaker:
|
|||
_PyFrame_SetStackPointer(frame, stack_pointer);
|
||||
new_frame->previous = frame;
|
||||
frame = cframe.current_frame = new_frame;
|
||||
CALL_STAT_INC(inlined_py_calls);
|
||||
goto start_frame;
|
||||
}
|
||||
|
||||
|
|
|
@ -163,9 +163,18 @@ print_spec_stats(FILE *out, OpcodeStats *stats)
|
|||
}
|
||||
#undef PRINT_STAT
|
||||
|
||||
|
||||
static void
|
||||
print_call_stats(FILE *out, CallStats *stats)
|
||||
{
|
||||
fprintf(out, "Calls to PyEval_EvalDefault: %" PRIu64 "\n", stats->pyeval_calls);
|
||||
fprintf(out, "Calls to Python functions inlined: %" PRIu64 "\n", stats->inlined_py_calls);
|
||||
}
|
||||
|
||||
static void
|
||||
print_stats(FILE *out, PyStats *stats) {
|
||||
print_spec_stats(out, stats->opcode_stats);
|
||||
print_call_stats(out, &stats->call_stats);
|
||||
}
|
||||
|
||||
void
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue