o
    ҷh+                     @  s  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
 G dd deZeG d	d
 d
ZeG dd dZeG dd dZdFddZdGddZdGddZdGddZdHddZ	dIdJd"d#ZdKd%d&Z	dIdLd)d*Z	dIdMd-d.ZdKd/d0Z		dNdOd3d4Z		dNdOd5d6Zed7eG d8d9 d9Zed:eG d;d< d<Zed=eG d>d? d?Zed@eG dAdB dBZedCeG dDdE dEZ dS )P    )annotations   )event_classT_JSON_DICT)	dataclassN)runtimec                      s8   e Zd ZdZdddZedddZ fd	d
Z  ZS )HeapSnapshotObjectIdz"
    Heap snapshot object id.
    returnstrc                 C  s   | S N selfr   r   g/var/www/html/venv/lib/python3.10/site-packages/selenium/webdriver/common/devtools/v85/heap_profiler.pyto_json   s   zHeapSnapshotObjectId.to_jsonjsonc                 C  s   | |S r   r   clsr   r   r   r   	from_json   s   zHeapSnapshotObjectId.from_jsonc                   s   d t  S )NzHeapSnapshotObjectId({}))formatsuper__repr__r   	__class__r   r   r      s   zHeapSnapshotObjectId.__repr__)r	   r
   )r   r
   r	   r   )	__name__
__module____qualname____doc__r   classmethodr   r   __classcell__r   r   r   r   r      s    
r   c                   @  sF   e Zd ZU dZded< ded< ded< ded	< d
d Zedd ZdS )SamplingHeapProfileNodezh
    Sampling Heap Profile node. Holds callsite information, allocation statistics and child nodes.
    zruntime.CallFrame
call_framefloat	self_sizeintid_z$typing.List[SamplingHeapProfileNode]childrenc                 C  s@   t  }| j |d< | j|d< | j|d< dd | jD |d< |S )N	callFrameselfSizeidc                 S     g | ]}|  qS r   r   .0ir   r   r   
<listcomp>4       z3SamplingHeapProfileNode.to_json.<locals>.<listcomp>r&   )dictr!   r   r#   r%   r&   r   r   r   r   r   r   /   s   

zSamplingHeapProfileNode.to_jsonc                 C  s:   | t j|d t|d t|d dd |d D dS )Nr'   r(   r)   c                 S     g | ]}t |qS r   r    r   r,   r   r   r   r/   =       z5SamplingHeapProfileNode.from_json.<locals>.<listcomp>r&   )r!   r#   r%   r&   )r   	CallFramer   r"   r$   r   r   r   r   r   7   s   

z!SamplingHeapProfileNode.from_jsonNr   r   r   r   __annotations__r   r   r   r   r   r   r   r       s   
 r    c                   @  s>   e Zd ZU dZded< ded< ded< dd Zed	d
 ZdS )SamplingHeapProfileSamplez2
    A single sample from a sampling profile.
    r"   sizer$   node_idordinalc                 C  s(   t  }| j|d< | j|d< | j|d< |S )Nr:   nodeIdr<   )r1   r:   r;   r<   r2   r   r   r   r   P   s
   


z!SamplingHeapProfileSample.to_jsonc                 C  s&   | t |d t|d t |d dS )Nr:   r=   r<   )r:   r;   r<   )r"   r$   r   r   r   r   r   W   s
   


z#SamplingHeapProfileSample.from_jsonNr7   r   r   r   r   r9   A   s   
 r9   c                   @  s6   e Zd ZU dZded< ded< dd Zedd	 Zd
S )SamplingHeapProfilez
    Sampling profile.
    r    headz&typing.List[SamplingHeapProfileSample]samplesc                 C  s,   t  }| j |d< dd | jD |d< |S )Nr?   c                 S  r*   r   r+   r,   r   r   r   r/   l   r0   z/SamplingHeapProfile.to_json.<locals>.<listcomp>r@   )r1   r?   r   r@   r2   r   r   r   r   i   s   zSamplingHeapProfile.to_jsonc                 C  s$   | t |d dd |d D dS )Nr?   c                 S  r3   r   )r9   r   r,   r   r   r   r/   s   r5   z1SamplingHeapProfile.from_json.<locals>.<listcomp>r@   )r?   r@   r4   r   r   r   r   r   o   s   zSamplingHeapProfile.from_jsonNr7   r   r   r   r   r>   `   s   
 r>   heap_object_idr	   0typing.Generator[T_JSON_DICT, T_JSON_DICT, None]c                 c  s(    t  }|  |d< d|d}|V }dS )z
    Enables console to refer to the node with given id via $x (see Command Line API for more details
    $x functions).

    :param heap_object_id: Heap snapshot object id to be accessible by means of $x command line API.
    heapObjectIdz#HeapProfiler.addInspectedHeapObjectmethodparamsN)r1   r   )rA   rF   cmd_dictr   r   r   r   add_inspected_heap_objectw   s   	
rH   c                  c      ddi} | V }d S )NrE   zHeapProfiler.collectGarbager   rG   r   r   r   r   collect_garbage      
rK   c                  c  rI   )NrE   zHeapProfiler.disabler   rJ   r   r   r   disable   rL   rM   c                  c  rI   )NrE   zHeapProfiler.enabler   rJ   r   r   r   enable   rL   rN   	object_idruntime.RemoteObjectId@typing.Generator[T_JSON_DICT, T_JSON_DICT, HeapSnapshotObjectId]c                 c  s2    t  }|  |d< d|d}|V }t|d S )z
    :param object_id: Identifier of the object to get heap object id for.
    :returns: Id of the heap snapshot object corresponding to the passed remote object id.
    objectIdzHeapProfiler.getHeapObjectIdrD   heapSnapshotObjectId)r1   r   r   r   )rO   rF   rG   r   r   r   r   get_heap_object_id   s   rT   object_grouptyping.Optional[str]@typing.Generator[T_JSON_DICT, T_JSON_DICT, runtime.RemoteObject]c                 c  sD    t  }|  |d< |dur||d< d|d}|V }tj|d S )z
    :param object_id:
    :param object_group: *(Optional)* Symbolic group name that can be used to release multiple objects.
    :returns: Evaluation result.
    rR   NobjectGroupz$HeapProfiler.getObjectByHeapObjectIdrD   result)r1   r   r   RemoteObjectr   )rO   rU   rF   rG   r   r   r   r   get_object_by_heap_object_id   s   	r[   ?typing.Generator[T_JSON_DICT, T_JSON_DICT, SamplingHeapProfile]c                  c      ddi} | V }t |d S )zB


    :returns: Return the sampling profile being collected.
    rE   zHeapProfiler.getSamplingProfileprofiler>   r   rJ   r   r   r   get_sampling_profile   
   r`   sampling_intervaltyping.Optional[float]c                 c  ,    t  }| dur| |d< d|d}|V }dS )z
    :param sampling_interval: *(Optional)* Average sample interval in bytes. Poisson distribution is used for the intervals. The default value is 32768 bytes.
    NsamplingIntervalzHeapProfiler.startSamplingrD   r1   )rb   rF   rG   r   r   r   r   start_sampling      
rg   track_allocationstyping.Optional[bool]c                 c  rd   )z0
    :param track_allocations: *(Optional)*
    NtrackAllocationsz%HeapProfiler.startTrackingHeapObjectsrD   rf   )ri   rF   rG   r   r   r   r   start_tracking_heap_objects   rh   rl   c                  c  r]   )z5


    :returns: Recorded sampling heap profile.
    rE   zHeapProfiler.stopSamplingr^   r_   rJ   r   r   r   stop_sampling   ra   rm   report_progresstreat_global_objects_as_rootsc                 c  <    t  }| dur| |d< |dur||d< d|d}|V }dS )z
    :param report_progress: *(Optional)* If true 'reportHeapSnapshotProgress' events will be generated while snapshot is being taken when the tracking is stopped.
    :param treat_global_objects_as_roots: *(Optional)*
    NreportProgresstreatGlobalObjectsAsRootsz$HeapProfiler.stopTrackingHeapObjectsrD   rf   rn   ro   rF   rG   r   r   r   r   stop_tracking_heap_objects     
rt   c                 c  rp   )a  
    :param report_progress: *(Optional)* If true 'reportHeapSnapshotProgress' events will be generated while snapshot is being taken.
    :param treat_global_objects_as_roots: *(Optional)* If true, a raw snapshot without artifical roots will be generated
    Nrq   rr   zHeapProfiler.takeHeapSnapshotrD   rf   rs   r   r   r   take_heap_snapshot  ru   rv   z!HeapProfiler.addHeapSnapshotChunkc                   @  s$   e Zd ZU ded< ed	ddZdS )
AddHeapSnapshotChunkr
   chunkr   r   r	   c                 C  s   | t |d dS )Nrx   )rx   )r
   r   r   r   r   r   .  s   
zAddHeapSnapshotChunk.from_jsonN)r   r   r	   rw   r   r   r   r8   r   r   r   r   r   r   rw   )  s   
 rw   zHeapProfiler.heapStatsUpdatec                   @  s(   e Zd ZU dZded< ed
ddZd	S )HeapStatsUpdatezj
    If heap objects tracking has been started then backend may send update for one or more fragments
    ztyping.List[int]stats_updater   r   r	   c                 C  s   | dd |d D dS )Nc                 S  s   g | ]}t |qS r   )r$   r,   r   r   r   r/   C  r0   z-HeapStatsUpdate.from_json.<locals>.<listcomp>statsUpdate)r{   r   r   r   r   r   r   @  s   zHeapStatsUpdate.from_jsonN)r   r   r	   rz   r   r   r   r   r8   r   r   r   r   r   r   rz   5  s
   
 rz   zHeapProfiler.lastSeenObjectIdc                   @  s0   e Zd ZU dZded< ded< edd	d
ZdS )LastSeenObjectIda(  
    If heap objects tracking has been started then backend regularly sends a current value for last
    seen object id and corresponding timestamp. If the were changes in the heap since last event
    then one or more heapStatsUpdate events will be sent before a new lastSeenObjectId event.
    r$   last_seen_object_idr"   	timestampr   r   r	   c                 C  s   | t |d t|d dS )NlastSeenObjectIdr   )r   r   )r$   r"   r   r   r   r   r   R  s   

zLastSeenObjectId.from_jsonN)r   r   r	   r~   r}   r   r   r   r   r~   G  s   
 r~   z'HeapProfiler.reportHeapSnapshotProgressc                   @  s4   e Zd ZU ded< ded< ded< edd	d
ZdS )ReportHeapSnapshotProgressr$   donetotalrj   finishedr   r   r	   c                 C  s6   | t |d t |d d|v rt|d dS d dS )Nr   r   r   )r   r   r   )r$   boolr   r   r   r   r   a  s   

z$ReportHeapSnapshotProgress.from_jsonN)r   r   r	   r   ry   r   r   r   r   r   Z  s   
 r   zHeapProfiler.resetProfilesc                   @  s   e Zd ZedddZdS )ResetProfilesr   r   r	   c                 C  s   |  S r   r   r   r   r   r   r   o  s   zResetProfiles.from_jsonN)r   r   r	   r   )r   r   r   r   r   r   r   r   r   r   j  s    r   )rA   r   r	   rB   )r	   rB   )rO   rP   r	   rQ   r   )rO   r   rU   rV   r	   rW   )r	   r\   )rb   rc   r	   rB   )ri   rj   r	   rB   )NN)rn   rj   ro   rj   r	   rB   )!
__future__r   utilr   r   dataclassesr   enumtyping r   r
   r   r    r9   r>   rH   rK   rM   rN   rT   r[   r`   rg   rl   rm   rt   rv   rw   rz   r~   r   r   r   r   r   r   <module>   s^   "







