a
    $ñ»j�  ã                   @  s  d dl mZ d dlZd dlZd dlmZ ddlmZ G dd„ dejƒZ	eG dd	„ d	ƒƒZ
eG d
d„ dƒƒZeG dd„ dƒƒZddœdd„Zddœdd„Zddœdd„Zdddœdd„Zdddœdd„Zd,dddd œd!d"„Zddœd#d$„Zd%dœd&d'„Zd%dœd(d)„Zd%dœd*d+„ZdS )-é    )ÚannotationsN)Ú	dataclassé   )ÚT_JSON_DICTc                   @  s:   e Zd ZdZdZdZddœdd„Zedd dœd	d
„ƒZdS )ÚPressureLevelzMemory pressure level.ZmoderateÚcriticalÚstr©Úreturnc                 C  s   | j S ©N)Úvalue)Úself© r   ú2E:\soccer\ml_env\Lib\site-packages\mycdp/memory.pyÚto_json   s    zPressureLevel.to_json©Újsonr
   c                 C  s   | |ƒS r   r   ©Úclsr   r   r   r   Ú	from_json   s    zPressureLevel.from_jsonN)	Ú__name__Ú
__module__Ú__qualname__Ú__doc__ZMODERATEÚCRITICALr   Úclassmethodr   r   r   r   r   r      s   r   c                   @  sL   e Zd ZU dZded< ded< ded< ddœd	d
„Zedd dœdd„ƒZdS )ÚSamplingProfileNodezHeap profile sample.ÚfloatÚsizeÚtotalztyping.List[str]Ústackr   r	   c                 C  s2   t ƒ }| j|d< | j|d< dd„ | jD ƒ|d< |S )Nr   r   c                 S  s   g | ]}|‘qS r   r   ©Ú.0Úir   r   r   Ú
<listcomp>*   ó    z/SamplingProfileNode.to_json.<locals>.<listcomp>r    )Údictr   r   r    ©r   r   r   r   r   r   &   s
    

zSamplingProfileNode.to_jsonr   c                 C  s0   | t | d¡ƒt | d¡ƒdd„ |d D ƒd�S )Nr   r   c                 S  s   g | ]}t |ƒ‘qS r   )r   r!   r   r   r   r$   2   r%   z1SamplingProfileNode.from_json.<locals>.<listcomp>r    )r   r   r    )r   Úgetr   r   r   r   r   -   s
    ýzSamplingProfileNode.from_jsonN©r   r   r   r   Ú__annotations__r   r   r   r   r   r   r   r      s   
r   c                   @  sD   e Zd ZU dZded< ded< ddœdd	„Zedd d
œdd„ƒZdS )ÚSamplingProfilezArray of heap profile samples.z typing.List[SamplingProfileNode]Úsamplesztyping.List[Module]Úmodulesr   r	   c                 C  s2   t ƒ }dd„ | jD ƒ|d< dd„ | jD ƒ|d< |S )Nc                 S  s   g | ]}|  ¡ ‘qS r   ©r   r!   r   r   r   r$   >   r%   z+SamplingProfile.to_json.<locals>.<listcomp>r,   c                 S  s   g | ]}|  ¡ ‘qS r   r.   r!   r   r   r   r$   ?   r%   r-   )r&   r,   r-   r'   r   r   r   r   <   s    zSamplingProfile.to_jsonr   c                 C  s(   | dd„ |d D ƒdd„ |d D ƒd�S )Nc                 S  s   g | ]}t  |¡‘qS r   )r   r   r!   r   r   r   r$   E   s   z-SamplingProfile.from_json.<locals>.<listcomp>r,   c                 S  s   g | ]}t  |¡‘qS r   )ÚModuler   r!   r   r   r   r$   H   r%   r-   )r,   r-   r   r   r   r   r   r   B   s    ÿüzSamplingProfile.from_jsonNr)   r   r   r   r   r+   6   s   
r+   c                   @  sT   e Zd ZU dZded< ded< ded< ded< dd	œd
d„Zedd dœdd„ƒZdS )r/   zExecutable module informationr   ÚnameÚuuidÚbase_addressr   r   r   r	   c                 C  s2   t ƒ }| j|d< | j|d< | j|d< | j|d< |S )Nr0   r1   ÚbaseAddressr   )r&   r0   r1   r2   r   r'   r   r   r   r   Y   s    



zModule.to_jsonr   c                 C  s8   | t | d¡ƒt | d¡ƒt | d¡ƒt| d¡ƒd�S )Nr0   r1   r3   r   )r0   r1   r2   r   )r   r(   r   r   r   r   r   r   a   s    üzModule.from_jsonNr)   r   r   r   r   r/   L   s   
r/   zGtyping.Generator[T_JSON_DICT, T_JSON_DICT, typing.Tuple[int, int, int]]r	   c                  c  s6   ddi} | V }t | d¡ƒt | d¡ƒt | d¡ƒfS )z‰
    :returns: A tuple with the following items:
        0. **documents** -
        1. **nodes** -
        2. **jsEventListeners** -
    ÚmethodzMemory.getDOMCountersZ	documentsÚnodesZjsEventListeners)Úintr(   ©Úcmd_dictr   r   r   r   Úget_dom_countersk   s    
ÿýr9   z0typing.Generator[T_JSON_DICT, T_JSON_DICT, None]c                  c  s   ddi} | V }d S )Nr4   zMemory.prepareForLeakDetectionr   r7   r   r   r   Úprepare_for_leak_detection   s    ÿr:   c                  c  s   ddi} | V }dS )z.Simulate OomIntervention by purging V8 memory.r4   z$Memory.forciblyPurgeJavaScriptMemoryNr   r7   r   r   r   Ú!forcibly_purge_java_script_memoryˆ   s    ÿr;   Úbool)Ú
suppressedr
   c                 c  s"   t ƒ }| |d< d|dœ}|V }dS )z«
    Enable/disable suppressing memory pressure notifications in all processes.
    :param suppressed:
     If true, memory pressure notifications will be suppressed.
    r=   z)Memory.setPressureNotificationsSuppressed©r4   ÚparamsN©r&   )r=   r?   r8   r   r   r   r   Ú%set_pressure_notifications_suppressed’   s    þrA   )Úlevelr
   c                 c  s&   t ƒ }|  ¡ |d< d|dœ}|V }dS )z€
    Simulate a memory pressure notification in all processes.
    :param level: Memory pressure level of the notification.
    rB   z#Memory.simulatePressureNotificationr>   N)r&   r   )rB   r?   r8   r   r   r   r   Úsimulate_pressure_notification£   s    þrC   ztyping.Optional[int]ztyping.Optional[bool])Úsampling_intervalÚsuppress_randomnessr
   c                 c  s:   t ƒ }| dur| |d< |dur&||d< d|dœ}|V }dS )zè
    Start collecting native memory profile.
    :param sampling_interval: *(Optional)*
     Average number of bytes between samples.
    :param suppress_randomness: *(Optional)*
     Do not randomize intervals between samples.
    NZsamplingIntervalZsuppressRandomnesszMemory.startSamplingr>   r@   )rD   rE   r?   r8   r   r   r   r   Ústart_sampling³   s    þrF   c                  c  s   ddi} | V }dS )z&Stop collecting native memory profile.r4   zMemory.stopSamplingNr   r7   r   r   r   Ústop_samplingÊ   s    ÿrG   z;typing.Generator[T_JSON_DICT, T_JSON_DICT, SamplingProfile]c                  c  s   ddi} | V }t  | d¡¡S )zb
    Retrieve native memory allocations profile
    collected since renderer process startup.
    r4   z Memory.getAllTimeSamplingProfileÚprofile©r+   r   r(   r7   r   r   r   Úget_all_time_sampling_profileÒ   s    ÿrJ   c                  c  s   ddi} | V }t  | d¡¡S )za
    Retrieve native memory allocations profile
    collected since browser process startup.
    r4   z Memory.getBrowserSamplingProfilerH   rI   r7   r   r   r   Úget_browser_sampling_profileà   s    ÿrK   c                  c  s   ddi} | V }t  | d¡¡S )zc
    Retrieve native memory allocations profile collected since last
    `startSampling` call.
    r4   zMemory.getSamplingProfilerH   rI   r7   r   r   r   Úget_sampling_profileî   s    ÿrL   )NN)Ú
__future__r   ÚenumÚtypingÚdataclassesr   Úutilr   ÚEnumr   r   r+   r/   r9   r:   r;   rA   rC   rF   rG   rJ   rK   rL   r   r   r   r   Ú<module>   s.   	
  þ