Profiler¶
Types¶
Generally, you do not need to instantiate CDP types yourself. Instead, the API creates objects for you as return values from commands, and then you can use those objects as arguments to other commands.
-
class
cdp.profiler.
ProfileNode
(id_, call_frame, hit_count=None, children=None, deopt_reason=None, position_ticks=None)¶ Profile node. Holds callsite information, execution statistics and child nodes.
-
call_frame
= None¶ Function location.
-
children
= None¶ Child node ids.
-
deopt_reason
= None¶ The reason of being not optimized. The function may be deoptimized or marked as don’t optimize.
-
hit_count
= None¶ Number of samples where this node was on top of the call stack.
-
id_
= None¶ Unique id of the node.
-
position_ticks
= None¶ An array of source position ticks.
-
-
class
cdp.profiler.
Profile
(nodes, start_time, end_time, samples=None, time_deltas=None)¶ Profile.
-
end_time
= None¶ Profiling end timestamp in microseconds.
-
nodes
= None¶ The list of profile nodes. First item is the root node.
-
samples
= None¶ Ids of samples top nodes.
-
start_time
= None¶ Profiling start timestamp in microseconds.
-
time_deltas
= None¶ Time intervals between adjacent samples in microseconds. The first delta is relative to the profile startTime.
-
-
class
cdp.profiler.
PositionTickInfo
(line, ticks)¶ Specifies a number of samples attributed to a certain source position.
-
line
= None¶ Source line number (1-based).
-
ticks
= None¶ Number of samples attributed to the source line.
-
-
class
cdp.profiler.
CoverageRange
(start_offset, end_offset, count)¶ Coverage data for a source range.
-
count
= None¶ Collected execution count of the source range.
-
end_offset
= None¶ JavaScript script source offset for the range end.
-
start_offset
= None¶ JavaScript script source offset for the range start.
-
-
class
cdp.profiler.
FunctionCoverage
(function_name, ranges, is_block_coverage)¶ Coverage data for a JavaScript function.
-
function_name
= None¶ JavaScript function name.
-
is_block_coverage
= None¶ Whether coverage data for this function has block granularity.
-
ranges
= None¶ Source ranges inside the function with coverage data.
-
-
class
cdp.profiler.
ScriptCoverage
(script_id, url, functions)¶ Coverage data for a JavaScript script.
-
functions
= None¶ Functions contained in the script that has coverage data.
-
script_id
= None¶ JavaScript script id.
-
url
= None¶ JavaScript script name or url.
-
-
class
cdp.profiler.
TypeObject
(name)¶ Describes a type collected during runtime.
-
name
= None¶ Name of a type collected with type profiling.
-
-
class
cdp.profiler.
TypeProfileEntry
(offset, types)¶ Source offset and types for a parameter or return value.
-
offset
= None¶ Source offset of the parameter or end of function for return values.
-
types
= None¶ The types for this parameter or return value.
-
-
class
cdp.profiler.
ScriptTypeProfile
(script_id, url, entries)¶ Type profile data collected during runtime for a JavaScript script.
-
entries
= None¶ Type profile entries for parameters and return values of the functions in the script.
-
script_id
= None¶ JavaScript script id.
-
url
= None¶ JavaScript script name or url.
-
Commands¶
Each command is a generator function. The return
type Generator[x, y, z]
indicates that the generator
yields arguments of type x
, it must be resumed with
an argument of type y
, and it returns type z
. In
this library, types x
and y
are the same for all
commands, and z
is the return type you should pay attention
to. For more information, see
Getting Started: Commands.
-
cdp.profiler.
disable
()¶ Return type: Generator
[Dict
[str
,Any
],Dict
[str
,Any
],None
]
-
cdp.profiler.
enable
()¶ Return type: Generator
[Dict
[str
,Any
],Dict
[str
,Any
],None
]
-
cdp.profiler.
get_best_effort_coverage
()¶ Collect coverage data for the current isolate. The coverage data may be incomplete due to garbage collection.
Return type: Generator
[Dict
[str
,Any
],Dict
[str
,Any
],List
[ScriptCoverage
]]Returns: Coverage data for the current isolate.
-
cdp.profiler.
set_sampling_interval
(interval)¶ Changes CPU profiler sampling interval. Must be called before CPU profiles recording started.
Parameters: interval ( int
) – New sampling interval in microseconds.Return type: Generator
[Dict
[str
,Any
],Dict
[str
,Any
],None
]
-
cdp.profiler.
start
()¶ Return type: Generator
[Dict
[str
,Any
],Dict
[str
,Any
],None
]
-
cdp.profiler.
start_precise_coverage
(call_count=None, detailed=None)¶ Enable precise code coverage. Coverage data for JavaScript executed before enabling precise code coverage may be incomplete. Enabling prevents running optimized code and resets execution counters.
Parameters: - call_count (
Optional
[bool
]) – (Optional) Collect accurate call counts beyond simple ‘covered’ or ‘not covered’. - detailed (
Optional
[bool
]) – (Optional) Collect block-based coverage.
Return type: Generator
[Dict
[str
,Any
],Dict
[str
,Any
],None
]- call_count (
-
cdp.profiler.
start_type_profile
()¶ Enable type profile.
EXPERIMENTAL
Return type: Generator
[Dict
[str
,Any
],Dict
[str
,Any
],None
]
-
cdp.profiler.
stop
()¶ Return type: Generator
[Dict
[str
,Any
],Dict
[str
,Any
],Profile
]Returns: Recorded profile.
-
cdp.profiler.
stop_precise_coverage
()¶ Disable precise code coverage. Disabling releases unnecessary execution count records and allows executing optimized code.
Return type: Generator
[Dict
[str
,Any
],Dict
[str
,Any
],None
]
-
cdp.profiler.
stop_type_profile
()¶ Disable type profile. Disabling releases type profile data collected so far.
EXPERIMENTAL
Return type: Generator
[Dict
[str
,Any
],Dict
[str
,Any
],None
]
-
cdp.profiler.
take_precise_coverage
()¶ Collect coverage data for the current isolate, and resets execution counters. Precise code coverage needs to have started.
Return type: Generator
[Dict
[str
,Any
],Dict
[str
,Any
],List
[ScriptCoverage
]]Returns: Coverage data for the current isolate.
-
cdp.profiler.
take_type_profile
()¶ Collect type profile.
EXPERIMENTAL
Return type: Generator
[Dict
[str
,Any
],Dict
[str
,Any
],List
[ScriptTypeProfile
]]Returns: Type profile for all scripts since startTypeProfile() was turned on.
Events¶
Generally, you do not need to instantiate CDP events yourself. Instead, the API creates events for you and then you use the event’s attributes.