1- from _typeshed import StrOrBytesPath , SupportsGet
1+ from _typeshed import StrOrBytesPath , SupportsGet , SupportsKeysAndGet
22from abc import ABCMeta
3+ from collections import Counter
34from collections .abc import Sequence
5+ from typing import Literal , TypeAlias , TypedDict , type_check_only
6+ from typing_extensions import Required
47
58from _remote_debugging import AwaitedInfo , InterpreterInfo
69
7- from .collector import Collector , _Frame , _Timestamps
10+ from .collector import Collector , _Frame , _Location , _Timestamps
11+
12+ # type check only
13+ # TODO: move to binary_collector.pyi when that is added
14+ _CaptureFeatureKeys : TypeAlias = Literal ["all_threads" , "native" , "gc" , "opcodes" , "blocking" ]
815
916class StackTraceCollector (Collector , metaclass = ABCMeta ):
17+ sample_interval_usec : int
18+ skip_idle : bool
19+
1020 def __init__ (self , sample_interval_usec : int , * , skip_idle : bool = False ) -> None : ...
1121 def collect (
1222 self , stack_frames : Sequence [InterpreterInfo ] | Sequence [AwaitedInfo ], timestamps_us : _Timestamps = None
1323 ) -> None : ...
1424 def process_frames (self , frames : Sequence [_Frame ], thread_id : int , weight : int = 1 ) -> None : ...
1525
1626class CollapsedStackCollector (StackTraceCollector ):
27+ stack_counter : Counter [tuple [tuple [str , _Location , str ], int ]]
1728 def __init__ (self , sample_interval_usec : int , * , skip_idle : bool = False ) -> None : ...
1829 def process_frames (self , frames : Sequence [_Frame ], thread_id : int , weight : int = 1 ) -> None : ...
1930 def export (self , filename : StrOrBytesPath ) -> None : ...
2031
32+ @type_check_only
33+ class _FlamegraphCollectorStats (TypedDict , total = False ):
34+ sample_interval_usec : Required [int ]
35+ duration_sec : float
36+ sample_rate : float
37+ error_rate : float | None
38+ missed_samples : float | None
39+ mode : int | None
40+
41+ @type_check_only
42+ class _ThreadStatusCounts (TypedDict ):
43+ has_gil : int
44+ on_cpu : int
45+ gil_requested : int
46+ unknown : int
47+ has_exception : int
48+ total : int
49+
2150class FlamegraphCollector (StackTraceCollector ):
51+ stats : _FlamegraphCollectorStats
52+ thread_status_counts : _ThreadStatusCounts
53+ samples_with_gc_frames : int
54+ per_thread_stats : dict [int , _ThreadStatusCounts ]
55+
2256 def __init__ (self , sample_interval_usec : int , * , skip_idle : bool = False ) -> None : ...
2357 def collect (
2458 self , stack_frames : Sequence [InterpreterInfo ] | Sequence [AwaitedInfo ], timestamps_us : _Timestamps = None
@@ -33,8 +67,21 @@ class FlamegraphCollector(StackTraceCollector):
3367 mode : int | None = None ,
3468 ) -> None : ...
3569 def set_replay_stats (self , info : SupportsGet [str , float | None ]) -> None : ...
70+ def set_mode (self , mode : int | None ) -> None : ...
3671 def export (self , filename : StrOrBytesPath ) -> None : ...
3772 def process_frames (self , frames : Sequence [_Frame ], thread_id : int , weight : int = 1 ) -> None : ...
3873
3974class DiffFlamegraphCollector (FlamegraphCollector ):
40- def __init__ (self , sample_interval_usec : int , * , baseline_binary_path : StrOrBytesPath , skip_idle : bool = False ) -> None : ...
75+ baseline_binary_path : StrOrBytesPath
76+ mode : int | None
77+ capture_config : SupportsKeysAndGet [_CaptureFeatureKeys , bool ] | None
78+
79+ def __init__ (
80+ self ,
81+ sample_interval_usec : int ,
82+ * ,
83+ baseline_binary_path : StrOrBytesPath ,
84+ skip_idle : bool = False ,
85+ mode : int | None = None ,
86+ capture_config : SupportsKeysAndGet [_CaptureFeatureKeys , bool ] | None = None ,
87+ ) -> None : ...
0 commit comments