
    aDg8                    B   d dl mZ d dlmZmZ d dlmZ d dlZd dlZddl	m
Z
 ddl	mZ e G d d	             Ze G d
 d             Ze G d d             Ze G d d             Ze G d d             Ze G d d             Ze G d d             Ze G d d             Ze G d d             Zd,dZd,dZd-dZ	 	 	 	 d.dZd,dZ	 	 d/	 	 	 	 	 d0dZd,d Zd1d!Zd,d"Zd,d#Zd-d$Zd2d%Z  ed&      e G d' d(                    Z! ed)      e G d* d+                    Z"y)3    )annotations)event_classT_JSON_DICT)	dataclassN   )debugger)runtimec                  x    e Zd ZU dZded<   ded<   dZded<   dZd	ed
<   dZded<   dZded<   ddZ	e
dd       Zy)ProfileNodezY
    Profile node. Holds callsite information, execution statistics and child nodes.
    intid_zruntime.CallFrame
call_frameNztyping.Optional[int]	hit_count!typing.Optional[typing.List[int]]childrentyping.Optional[str]deopt_reasonz.typing.Optional[typing.List[PositionTickInfo]]position_ticksc                   t               }| j                  |d<   | j                  j                         |d<   | j                  | j                  |d<   | j
                  | j
                  D cg c]  }| c}|d<   | j                  | j                  |d<   | j                  +| j                  D cg c]  }|j                          c}|d<   |S c c}w c c}w )Nid	callFramehitCountr   deoptReasonpositionTicks)dictr   r   to_jsonr   r   r   r   selfjsonis      L/var/www/highfloat_scraper/venv/lib/python3.12/site-packages/cdp/profiler.pyr   zProfileNode.to_json*   s     FXXT
 OO335[>>%#~~D==$+/==9a9D("&"3"3D*:>:M:M$NQQYY[$ND!  : %Os   ,	C0Cc                p    | t        |d         t        j                  j                  |d         d|v rt        |d         nd d|v r|d   D cg c]  }t        |       c}nd d|v rt	        |d         nd d|v r+|d   D cg c]  }t
        j                  |       c}      S d       S c c}w c c}w )Nr   r   r   r   r   r   )r   r   r   r   r   r   )r   r	   	CallFrame	from_jsonstrPositionTickInfoclsr   r    s      r!   r$   zProfileNode.from_json8   s    DJ((2243DE/9T/Ac$z*+t;E;Md:&67c!f7SW5Bd5JT-01PT]lpt]t4CXYa,66q9Y
 	
 {
 	
 8Ys   B.B3returnr   )r   r   r*   r   )__name__
__module____qualname____doc____annotations__r   r   r   r   r   classmethodr$        r!   r   r      se     
H "! '+I#* 37H/6 *.L&- FJNBI 
 
r2   r   c                  f    e Zd ZU dZded<   ded<   ded<   dZded	<   dZded
<   ddZedd       Z	y)Profilez
    Profile.
    ztyping.List[ProfileNode]nodesfloat
start_timeend_timeNr   samplestime_deltasc                n   t               }| j                  D cg c]  }|j                          c}|d<   | j                  |d<   | j                  |d<   | j
                  | j
                  D cg c]  }| c}|d<   | j                  | j                  D cg c]  }| c}|d<   |S c c}w c c}w c c}w )Nr5   	startTimeendTimer9   
timeDeltas)r   r5   r   r7   r8   r9   r:   r   s      r!   r   zProfile.to_jsonY   s     F.2jj99W OO[--Y<<#*.,,7Qq7DO'-1-=-=!>!!>D : 8!>s   B(.	B-	B2c                <    | |d   D cg c]  }t         j                  |       c}t        |d         t        |d         d|v r|d   D cg c]  }t        |       c}nd d|v r!|d   D cg c]  }t        |       c}      S d       S c c}w c c}w c c}w )Nr5   r<   r=   r9   r>   )r5   r7   r8   r9   r:   )r   r$   r6   r   r'   s      r!   r$   zProfile.from_jsond   s    59']C;((+CT+./4	?+9Bd9JT)_5SV5PT@LPT@Tl);<AQ<
 	

 [_
 	
C 6<s   BB.Br)   )r   r   r*   r4   )
r+   r,   r-   r.   r/   r9   r:   r   r0   r$   r1   r2   r!   r4   r4   D   sQ     $#  O 26G.5 6:K29	 
 
r2   r4   c                  @    e Zd ZU dZded<   ded<   ddZed	d       Zy)
r&   zP
    Specifies a number of samples attributed to a certain source position.
    r   lineticksc                V    t               }| j                  |d<   | j                  |d<   |S )NrA   rB   )r   rA   rB   r   r   s     r!   r   zPositionTickInfo.to_jsonz   s(     FyyV

Wr2   c                F     | t        |d         t        |d               S )NrA   rB   )rA   rB   r   r(   r   s     r!   r$   zPositionTickInfo.from_json   s'    T&\"d7m$
 	
r2   Nr)   )r   r   r*   r&   r+   r,   r-   r.   r/   r   r0   r$   r1   r2   r!   r&   r&   o   s.     I J 
 
r2   r&   c                  J    e Zd ZU dZded<   ded<   ded<   d	dZed
d       Zy)CoverageRangez+
    Coverage data for a source range.
    r   start_offset
end_offsetcountc                t    t               }| j                  |d<   | j                  |d<   | j                  |d<   |S )NstartOffset	endOffsetrM   )r   rK   rL   rM   rD   s     r!   r   zCoverageRange.to_json   s9     F"//] OO[

Wr2   c                `     | t        |d         t        |d         t        |d               S )NrO   rP   rM   )rK   rL   rM   rF   rG   s     r!   r$   zCoverageRange.from_json   s5    T-014,-d7m$
 	
r2   Nr)   )r   r   r*   rJ   rH   r1   r2   r!   rJ   rJ      s6      O J 
 
r2   rJ   c                  J    e Zd ZU dZded<   ded<   ded<   ddZedd	       Zy
)FunctionCoveragez2
    Coverage data for a JavaScript function.
    r%   function_nameztyping.List[CoverageRange]rangesboolis_block_coveragec                    t               }| j                  |d<   | j                  D cg c]  }|j                          c}|d<   | j                  |d<   |S c c}w )NfunctionNamerU   isBlockCoverage)r   rT   rU   r   rW   r   s      r!   r   zFunctionCoverage.to_json   sR     F#11^/3{{;!!))+;X"&"8"8 <s   Ac           	          | t        |d         |d   D cg c]  }t        j                  |       c}t        |d               S c c}w )NrY   rU   rZ   )rT   rU   rW   )r%   rJ   r$   rV   r'   s      r!   r$   zFunctionCoverage.from_json   sJ    d>238<XG1M++A.G"4(9#:;
 	
Gs   A
Nr)   )r   r   r*   rS   rH   r1   r2   r!   rS   rS      s8      '&  
 
r2   rS   c                  J    e Zd ZU dZded<   ded<   ded<   ddZedd	       Zy
)ScriptCoveragez0
    Coverage data for a JavaScript script.
    runtime.ScriptId	script_idr%   urlztyping.List[FunctionCoverage]	functionsc                    t               }| j                  j                         |d<   | j                  |d<   | j                  D cg c]  }|j                          c}|d<   |S c c}w )NscriptIdr`   ra   )r   r_   r   r`   ra   r   s      r!   r   zScriptCoverage.to_json   sW     F>>113ZhhU26..AQQYY[A[ B   A$c           
          | t         j                  j                  |d         t        |d         |d   D cg c]  }t        j                  |       c}      S c c}w )Nrc   r`   ra   )r_   r`   ra   )r	   ScriptIdr$   r%   rS   r'   s      r!   r$   zScriptCoverage.from_json   sY    &&00j1ABDK >B;>OP'11!4P
 	
 Q   ANr)   )r   r   r*   r]   rH   r1   r2   r!   r]   r]      s7       
H -, 
 
r2   r]   c                  6    e Zd ZU dZded<   ddZedd       Zy)	
TypeObjectz4
    Describes a type collected during runtime.
    r%   namec                8    t               }| j                  |d<   |S )Nrj   )r   rj   rD   s     r!   r   zTypeObject.to_json   s     FyyVr2   c                ,     | t        |d               S )Nrj   )rj   )r%   rG   s     r!   r$   zTypeObject.from_json   s    T&\"
 	
r2   Nr)   )r   r   r*   ri   rH   r1   r2   r!   ri   ri      s'     I
 
 
r2   ri   c                  @    e Zd ZU dZded<   ded<   d	dZed
d       Zy)TypeProfileEntryzB
    Source offset and types for a parameter or return value.
    r   offsetztyping.List[TypeObject]typesc                    t               }| j                  |d<   | j                  D cg c]  }|j                          c}|d<   |S c c}w )Nro   rp   )r   ro   rp   r   r   s      r!   r   zTypeProfileEntry.to_json  s>     FX.2jj99W :s   Ac           	          | t        |d         |d   D cg c]  }t        j                  |       c}      S c c}w )Nro   rp   )ro   rp   )r   ri   r$   r'   s      r!   r$   zTypeProfileEntry.from_json  s;    tH~&48MBq:''*B
 	
Bs   ;
Nr)   )r   r   r*   rn   rH   r1   r2   r!   rn   rn      s/     K #" 
 
r2   rn   c                  J    e Zd ZU dZded<   ded<   ded<   ddZedd	       Zy
)ScriptTypeProfilezM
    Type profile data collected during runtime for a JavaScript script.
    r^   r_   r%   r`   ztyping.List[TypeProfileEntry]entriesc                    t               }| j                  j                         |d<   | j                  |d<   | j                  D cg c]  }|j                          c}|d<   |S c c}w )Nrc   r`   ru   )r   r_   r   r`   ru   r   s      r!   r   zScriptTypeProfile.to_json  sU     F>>113ZhhU04=1199;=Y >rd   c           
          | t         j                  j                  |d         t        |d         |d   D cg c]  }t        j                  |       c}      S c c}w )Nrc   r`   ru   )r_   r`   ru   )r	   rf   r$   r%   rn   r'   s      r!   r$   zScriptTypeProfile.from_json$  sX    &&00j1ABDK <@OLq%//2L
 	
 Mrg   Nr)   )r   r   r*   rt   rH   r1   r2   r!   rt   rt     s7       
H +* 
 
r2   rt   c               #     K   ddi} | }y w)NmethodzProfiler.disabler1   cmd_dictr   s     r!   disabler|   -  s      	$H >D   
c               #     K   ddi} | }y w)Nry   zProfiler.enabler1   rz   s     r!   enabler   5  s      	#H >Dr}   c               #  p   K   ddi} | }|d   D cg c]  }t         j                  |       c}S c c}w w)z
    Collect coverage data for the current isolate. The coverage data may be incomplete due to
    garbage collection.

    :returns: Coverage data for the current isolate.
    ry   zProfiler.getBestEffortCoverageresultr]   r$   r{   r   r    s      r!   get_best_effort_coverager   =  sA      	2H >D15h@AN$$Q'@@@   616c              #  <   K   t               }| |d<   d|d}|}yw)z
    Changes CPU profiler sampling interval. Must be called before CPU profiles recording started.

    :param interval: New sampling interval in microseconds.
    intervalzProfiler.setSamplingIntervalry   paramsNr   )r   r   r{   r   s       r!   set_sampling_intervalr   K  s/      &F!F:0H >Ds   c               #     K   ddi} | }y w)Nry   zProfiler.startr1   rz   s     r!   startr   \  s      	"H >Dr}   c              #  N   K   t               }| | |d<   |||d<   d|d}|}yw)a  
    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.

    :param call_count: *(Optional)* Collect accurate call counts beyond simple 'covered' or 'not covered'.
    :param detailed: *(Optional)* Collect block-based coverage.
    N	callCountdetailedzProfiler.startPreciseCoverager   r   )
call_countr   r   r{   r   s        r!   start_precise_coverager   d  sE      &F({%z1H >Ds   #%c               #     K   ddi} | }yw)z4
    Enable type profile.

    **EXPERIMENTAL**
    ry   zProfiler.startTypeProfileNr1   rz   s     r!   start_type_profiler   |  s      	-H >Dr}   c               #  J   K   ddi} | }t         j                  |d         S w)z'


    :returns: Recorded profile.
    ry   zProfiler.stopprofile)r4   r$   rz   s     r!   stopr     s2      	/H >DT)_--s   !#c               #     K   ddi} | }yw)z
    Disable precise code coverage. Disabling releases unnecessary execution count records and allows
    executing optimized code.
    ry   zProfiler.stopPreciseCoverageNr1   rz   s     r!   stop_precise_coverager     s      	0H >Dr}   c               #     K   ddi} | }yw)zl
    Disable type profile. Disabling releases type profile data collected so far.

    **EXPERIMENTAL**
    ry   zProfiler.stopTypeProfileNr1   rz   s     r!   stop_type_profiler     s      	,H >Dr}   c               #  p   K   ddi} | }|d   D cg c]  }t         j                  |       c}S c c}w w)z
    Collect coverage data for the current isolate, and resets execution counters. Precise code
    coverage needs to have started.

    :returns: Coverage data for the current isolate.
    ry   zProfiler.takePreciseCoverager   r   r   s      r!   take_precise_coverager     sA      	0H >D15h@AN$$Q'@@@r   c               #  p   K   ddi} | }|d   D cg c]  }t         j                  |       c}S c c}w w)z
    Collect type profile.

    **EXPERIMENTAL**

    :returns: Type profile for all scripts since startTypeProfile() was turned on.
    ry   zProfiler.takeTypeProfiler   )rt   r$   r   s      r!   take_type_profiler     sB      	,H >D48NCq''*CCCr   zProfiler.consoleProfileFinishedc                  H    e Zd ZU ded<   ded<   ded<   ded<   edd	       Zy
)ConsoleProfileFinishedr%   r   debugger.Locationlocationr4   r   r   titlec           	          | t        |d         t        j                  j                  |d         t        j                  |d         d|v rt        |d               S d       S )Nr   r   r   r   )r   r   r   r   )r%   r   Locationr$   r4   rG   s     r!   r$   z ConsoleProfileFinished.from_json  sg    DJ&&00j1AB%%d9o6(/4#d7m$	
 	
 >B	
 	
r2   N)r   r   r*   r   )r+   r,   r-   r/   r0   r$   r1   r2   r!   r   r     s-     
H
 
r2   r   zProfiler.consoleProfileStartedc                  B    e Zd ZU dZded<   ded<   ded<   ed
d       Zy	)ConsoleProfileStartedzR
    Sent when new profile recording is started using console.profile() call.
    r%   r   r   r   r   r   c                     | t        |d         t        j                  j                  |d         d|v rt        |d               S d       S )Nr   r   r   )r   r   r   )r%   r   r   r$   rG   s     r!   r$   zConsoleProfileStarted.from_json  sU    DJ&&00j1AB(/4#d7m$
 	
 >B
 	
r2   N)r   r   r*   r   )r+   r,   r-   r.   r/   r0   r$   r1   r2   r!   r   r     s,     
H
 
r2   r   )r*   0typing.Generator[T_JSON_DICT, T_JSON_DICT, None])r*   zGtyping.Generator[T_JSON_DICT, T_JSON_DICT, typing.List[ScriptCoverage]])r   r   r*   r   )NN)r   typing.Optional[bool]r   r   r*   r   )r*   z3typing.Generator[T_JSON_DICT, T_JSON_DICT, Profile])r*   zJtyping.Generator[T_JSON_DICT, T_JSON_DICT, typing.List[ScriptTypeProfile]])#
__future__r   cdp.utilr   r   dataclassesr   enumtyping r   r	   r   r4   r&   rJ   rS   r]   ri   rn   rt   r|   r   r   r   r   r   r   r   r   r   r   r   r   r   r1   r2   r!   <module>r      s   # - !     .
 .
 .
b '
 '
 '
T 
 
 
0 
 
 
: 
 
 
: 
 
 
: 
 
 
& 
 
 
0 
 
 
:A	7" -1*.)' 
80	
.	AD ./

 
  0
$ -.

 
  /
r2   