Coverage Report

Created: 2022-07-08 09:39

/home/mdboom/Work/builds/cpython/Include/pystats.h
Line
Count
Source
1
2
3
#ifndef Py_PYSTATS_H
4
#define Py_PYSTATS_H
5
#ifdef __cplusplus
6
extern "C" {
7
#endif
8
9
#ifdef Py_STATS
10
11
#define SPECIALIZATION_FAILURE_KINDS 32
12
13
/* Stats for determining who is calling PyEval_EvalFrame */
14
#define EVAL_CALL_TOTAL 0
15
#define EVAL_CALL_VECTOR 1
16
#define EVAL_CALL_GENERATOR 2
17
#define EVAL_CALL_LEGACY 3
18
#define EVAL_CALL_FUNCTION_VECTORCALL 4
19
#define EVAL_CALL_BUILD_CLASS 5
20
#define EVAL_CALL_SLOT 6
21
#define EVAL_CALL_FUNCTION_EX 7
22
#define EVAL_CALL_API 8
23
#define EVAL_CALL_METHOD 9
24
25
#define EVAL_CALL_KINDS 10
26
27
typedef struct _specialization_stats {
28
    uint64_t success;
29
    uint64_t failure;
30
    uint64_t hit;
31
    uint64_t deferred;
32
    uint64_t miss;
33
    uint64_t deopt;
34
    uint64_t failure_kinds[SPECIALIZATION_FAILURE_KINDS];
35
} SpecializationStats;
36
37
typedef struct _opcode_stats {
38
    SpecializationStats specialization;
39
    uint64_t execution_count;
40
    uint64_t pair_count[256];
41
} OpcodeStats;
42
43
typedef struct _call_stats {
44
    uint64_t inlined_py_calls;
45
    uint64_t pyeval_calls;
46
    uint64_t frames_pushed;
47
    uint64_t frame_objects_created;
48
    uint64_t eval_calls[EVAL_CALL_KINDS];
49
} CallStats;
50
51
typedef struct _object_stats {
52
    uint64_t increfs;
53
    uint64_t decrefs;
54
    uint64_t interpreter_increfs;
55
    uint64_t interpreter_decrefs;
56
    uint64_t allocations;
57
    uint64_t allocations512;
58
    uint64_t allocations4k;
59
    uint64_t allocations_big;
60
    uint64_t frees;
61
    uint64_t to_freelist;
62
    uint64_t from_freelist;
63
    uint64_t new_values;
64
    uint64_t dict_materialized_on_request;
65
    uint64_t dict_materialized_new_key;
66
    uint64_t dict_materialized_too_big;
67
    uint64_t dict_materialized_str_subclass;
68
} ObjectStats;
69
70
typedef struct _stats {
71
    OpcodeStats opcode_stats[256];
72
    CallStats call_stats;
73
    ObjectStats object_stats;
74
} PyStats;
75
76
77
PyAPI_DATA(PyStats) _py_stats_struct;
78
PyAPI_DATA(PyStats *) _py_stats;
79
80
extern void _Py_StatsClear(void);
81
extern void _Py_PrintSpecializationStats(int to_file);
82
83
#ifdef _PY_INTERPRETER
84
85
#define _Py_INCREF_STAT_INC() do { if (_py_stats) _py_stats->object_stats.interpreter_increfs++; } while (0)
86
#define _Py_DECREF_STAT_INC() do { if (_py_stats) _py_stats->object_stats.interpreter_decrefs++; } while (0)
87
88
#else
89
90
#define _Py_INCREF_STAT_INC() do { if (_py_stats) _py_stats->object_stats.increfs++; } while (0)
91
#define _Py_DECREF_STAT_INC() do { if (_py_stats) _py_stats->object_stats.decrefs++; } while (0)
92
93
#endif
94
95
#else
96
97
#define _Py_INCREF_STAT_INC() ((void)0)
98
#define _Py_DECREF_STAT_INC() ((void)0)
99
100
#endif  // !Py_STATS
101
102
#ifdef __cplusplus
103
}
104
#endif
105
#endif /* !Py_PYSTATs_H */