mirror of
https://github.com/python/cpython.git
synced 2024-11-23 18:04:37 +08:00
a0773b89df
Statistics gathering is now off by default. Use the "-X pystats" command line option or set the new PYTHONSTATS environment variable to 1 to turn statistics gathering on at Python startup. Statistics are no longer dumped at exit if statistics gathering was off or statistics have been cleared. Changes: * Add PYTHONSTATS environment variable. * sys._stats_dump() now returns False if statistics are not dumped because they are all equal to zero. * Add PyConfig._pystats member. * Add tests on sys functions and on setting PyConfig._pystats to 1. * Add Include/cpython/pystats.h and Include/internal/pycore_pystats.h header files. * Rename '_py_stats' variable to '_Py_stats'. * Exclude Include/cpython/pystats.h from the Py_LIMITED_API. * Move pystats.h include from object.h to Python.h. * Add _Py_StatsOn() and _Py_StatsOff() functions. Remove '_py_stats_struct' variable from the API: make it static in specialize.c. * Document API in Include/pystats.h and Include/cpython/pystats.h. * Complete pystats documentation in Doc/using/configure.rst. * Don't write "all zeros" stats: if _stats_off() and _stats_clear() or _stats_dump() were called. * _PyEval_Fini() now always call _Py_PrintSpecializationStats() which does nothing if stats are all zeros. Co-authored-by: Michael Droettboom <mdboom@gmail.com>
27 lines
596 B
C
27 lines
596 B
C
// Statistics on Python performance (public API).
|
|
//
|
|
// Define _Py_INCREF_STAT_INC() and _Py_DECREF_STAT_INC() used by Py_INCREF()
|
|
// and Py_DECREF().
|
|
//
|
|
// See Include/cpython/pystats.h for the full API.
|
|
|
|
#ifndef Py_PYSTATS_H
|
|
#define Py_PYSTATS_H
|
|
#ifdef __cplusplus
|
|
extern "C" {
|
|
#endif
|
|
|
|
#if defined(Py_STATS) && !defined(Py_LIMITED_API)
|
|
# define Py_CPYTHON_PYSTATS_H
|
|
# include "cpython/pystats.h"
|
|
# undef Py_CPYTHON_PYSTATS_H
|
|
#else
|
|
# define _Py_INCREF_STAT_INC() ((void)0)
|
|
# define _Py_DECREF_STAT_INC() ((void)0)
|
|
#endif // !Py_STATS
|
|
|
|
#ifdef __cplusplus
|
|
}
|
|
#endif
|
|
#endif // !Py_PYSTATS_H
|