Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork33.7k
GH-93841: Turn stats on and off, clear and dump them at runtime.#93843
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Uh oh!
There was an error while loading.Please reload this page.
Changes from1 commit
4b142e6daa54876bc5fe2d6ce8e6cc0f61ee301cda4409affca65b2eFile filter
Filter by extension
Conversations
Uh oh!
There was an error while loading.Please reload this page.
Jump to
Uh oh!
There was an error while loading.Please reload this page.
Diff view
Diff view
- Loading branch information
Uh oh!
There was an error while loading.Please reload this page.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more abouthow customized files appear on GitHub.
Uh oh!
There was an error while loading.Please reload this page.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1909,6 +1909,63 @@ sys_is_finalizing_impl(PyObject *module) | ||
| return PyBool_FromLong(_Py_IsFinalizing()); | ||
| } | ||
| #ifdef Py_STATS | ||
| /*[clinic input] | ||
| sys._stats_on | ||
| Turns on stats gathering (stats gathering is on by default) | ||
| [clinic start generated code]*/ | ||
| static PyObject * | ||
| sys__stats_on_impl(PyObject *module) | ||
| /*[clinic end generated code: output=aca53eafcbb4d9fe input=f4bef5763c4387b8]*/ | ||
| static PyObject * | ||
| sys__stats_on(PyObject *module) | ||
| /*[clinic end generated code]*/ | ||
| { | ||
| _py_stats = &_py_stats_struct; | ||
| Py_RETURN_NONE; | ||
| } | ||
| /*[clinic input] | ||
| sys._stats_off | ||
| Turns off stats gathering (stats gathering is on by default) | ||
| [clinic start generated code]*/ | ||
| static PyObject * | ||
| sys__stats_off_impl(PyObject *module) | ||
| /*[clinic end generated code: output=1534c1ee63812214 input=ec6e593e39b12b4a]*/ | ||
| static PyObject * | ||
| sys__stats_off(PyObject *module) | ||
| /*[clinic end generated code]*/ | ||
| { | ||
| _py_stats = NULL; | ||
Member There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others.Learn more. Can we use a hidden, dummy brother of MemberAuthor There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others.Learn more. I did consider it, but the stats object is about 600k and is likely to get larger. So I think the extra NULL checks are less inefficient than wasting the memory. | ||
| Py_RETURN_NONE; | ||
| } | ||
| /*[clinic input] | ||
| sys._stats_clear | ||
| Clears stats | ||
| [clinic start generated code]*/ | ||
| static PyObject * | ||
| sys__stats_clear_impl(PyObject *module) | ||
| /*[clinic end generated code: output=fb65a2525ee50604 input=0bd23b30a48f67ab]*/ | ||
| static PyObject * | ||
| sys__stats_clear(PyObject *module) | ||
| /*[clinic end generated code]*/ | ||
| { | ||
| _Py_StatsClear(); | ||
| Py_RETURN_NONE; | ||
| } | ||
| #endif | ||
| #ifdef ANDROID_API_LEVEL | ||
| /*[clinic input] | ||
| sys.getandroidapilevel | ||
| @@ -1978,6 +2035,11 @@ static PyMethodDef sys_methods[] = { | ||
| SYS_GET_ASYNCGEN_HOOKS_METHODDEF | ||
| SYS_GETANDROIDAPILEVEL_METHODDEF | ||
| SYS_UNRAISABLEHOOK_METHODDEF | ||
| #ifdef Py_STATS | ||
| SYS__STATS_ON_METHODDEF | ||
| SYS__STATS_OFF_METHODDEF | ||
| SYS__STATS_CLEAR_METHODDEF | ||
| #endif | ||
| {NULL, NULL} // sentinel | ||
| }; | ||