a
    $ñ»jã9  ã                   @  sÚ  d dl mZ d dlZd dlmZ ddlmZm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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d„ZdEddd d!œd"d#„Zd$dœd%d&„ZdFd'd(d(dd)œd*d+„ZdGd(dd,œd-d.„Zd$dœd/d0„ZdHd(d(d(d(dd1œd2d3„ZdId(d(d(d(dd1œd4d5„Zed6ƒeG d7d8„ d8ƒƒƒZed9ƒeG d:d;„ d;ƒƒƒZed<ƒeG d=d>„ d>ƒƒƒZed?ƒeG d@dA„ dAƒƒƒZedBƒeG dCdD„ dDƒƒƒZdS )Jé    )ÚannotationsN)Ú	dataclassé   )Úevent_classÚT_JSON_DICT)Úruntimec                      sB   e Zd ZdZddœdd„Zedd dœdd„ƒZ‡ fd	d
„Z‡  ZS )ÚHeapSnapshotObjectIdzHeap snapshot object id.Ústr©Úreturnc                 C  s   | S ©N© ©Úselfr   r   ú9E:\soccer\ml_env\Lib\site-packages\mycdp/heap_profiler.pyÚto_json   s    zHeapSnapshotObjectId.to_json©Újsonr   c                 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__)	Ú__name__Ú
__module__Ú__qualname__Ú__doc__r   Úclassmethodr   r   Ú__classcell__r   r   r   r   r      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 )ÚSamplingHeapProfileNodezl
    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]Úchildrenr   r
   c                 C  s@   t ƒ }| j ¡ |d< | j|d< | j|d< dd„ | jD ƒ|d< |S )NÚ	callFrameÚselfSizeÚidc                 S  s   g | ]}|  ¡ ‘qS r   ©r   ©Ú.0Úir   r   r   Ú
<listcomp>2   ó    z3SamplingHeapProfileNode.to_json.<locals>.<listcomp>r(   )Údictr#   r   r%   r'   r(   ©r   r   r   r   r   r   -   s    

zSamplingHeapProfileNode.to_jsonr   c                 C  s@   | t j | d¡¡t| d¡ƒt| d¡ƒdd„ |d D ƒd�S )Nr)   r*   r+   c                 S  s   g | ]}t  |¡‘qS r   )r"   r   r-   r   r   r   r0   ;   s   z5SamplingHeapProfileNode.from_json.<locals>.<listcomp>r(   )r#   r%   r'   r(   )r   Z	CallFramer   Úgetr$   r&   r   r   r   r   r   5   s    ÿüz!SamplingHeapProfileNode.from_jsonN©r   r   r   r   Ú__annotations__r   r    r   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 )ÚSamplingHeapProfileSamplez(A single sample from a sampling profile.r$   Úsizer&   Únode_idÚordinalr   r
   c                 C  s(   t ƒ }| j|d< | j|d< | j|d< |S )Nr8   ÚnodeIdr:   )r2   r8   r9   r:   r3   r   r   r   r   M   s
    


z!SamplingHeapProfileSample.to_jsonr   c                 C  s,   | t | d¡ƒt| d¡ƒt | d¡ƒd�S )Nr8   r;   r:   )r8   r9   r:   )r$   r4   r&   r   r   r   r   r   T   s
    ýz#SamplingHeapProfileSample.from_jsonNr5   r   r   r   r   r7   A   s   
r7   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 )ÚSamplingHeapProfilezSampling profile.r"   Úheadz&typing.List[SamplingHeapProfileSample]Úsamplesr   r
   c                 C  s,   t ƒ }| j ¡ |d< dd„ | jD ƒ|d< |S )Nr=   c                 S  s   g | ]}|  ¡ ‘qS r   r,   r-   r   r   r   r0   f   r1   z/SamplingHeapProfile.to_json.<locals>.<listcomp>r>   )r2   r=   r   r>   r3   r   r   r   r   c   s    zSamplingHeapProfile.to_jsonr   c                 C  s&   | t  | d¡¡dd„ |d D ƒd�S )Nr=   c                 S  s   g | ]}t  |¡‘qS r   )r7   r   r-   r   r   r   r0   m   s   z1SamplingHeapProfile.from_json.<locals>.<listcomp>r>   )r=   r>   )r"   r   r4   r   r   r   r   r   i   s    ÿþzSamplingHeapProfile.from_jsonNr5   r   r   r   r   r<   ]   s   
r<   z0typing.Generator[T_JSON_DICT, T_JSON_DICT, None])Úheap_object_idr   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.
    ZheapObjectIdz#HeapProfiler.addInspectedHeapObject©ÚmethodÚparamsN)r2   r   )r?   rB   Úcmd_dictr   r   r   r   Úadd_inspected_heap_objects   s    	þrD   r
   c                  c  s   ddi} | V }d S )NrA   zHeapProfiler.collectGarbager   ©rC   r   r   r   r   Úcollect_garbage…   s    ÿrF   c                  c  s   ddi} | V }d S )NrA   zHeapProfiler.disabler   rE   r   r   r   ÚdisableŒ   s    ÿrG   c                  c  s   ddi} | V }d S )NrA   zHeapProfiler.enabler   rE   r   r   r   Úenable“   s    ÿrH   zruntime.RemoteObjectIdz@typing.Generator[T_JSON_DICT, T_JSON_DICT, HeapSnapshotObjectId])Ú	object_idr   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.getHeapObjectIdr@   ZheapSnapshotObjectId)r2   r   r   r   r4   )rI   rB   rC   r   r   r   r   Úget_heap_object_idš   s    þrK   ztyping.Optional[str]z@typing.Generator[T_JSON_DICT, T_JSON_DICT, runtime.RemoteObject])rI   Úobject_groupr   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.
    rJ   NZobjectGroupz$HeapProfiler.getObjectByHeapObjectIdr@   Úresult)r2   r   r   ZRemoteObjectr   r4   )rI   rL   rB   rC   r   r   r   r   Úget_object_by_heap_object_id¬   s    	þrN   z?typing.Generator[T_JSON_DICT, T_JSON_DICT, SamplingHeapProfile]c                  c  s   ddi} | V }t  | d¡¡S )z@
    :returns: Return the sampling profile being collected.
    rA   zHeapProfiler.getSamplingProfileÚprofile©r<   r   r4   rE   r   r   r   Úget_sampling_profileÁ   s    ÿrQ   ztyping.Optional[float]útyping.Optional[bool])Úsampling_intervalÚ%include_objects_collected_by_major_gcÚ%include_objects_collected_by_minor_gcr   c                 c  sJ   t ƒ }| dur| |d< |dur&||d< |dur6||d< d|dœ}|V }dS )a÷  
    :param sampling_interval: *(Optional)*
     Average sample interval in bytes.
     Poisson distribution is used for the intervals.
     The default value is 32768 bytes.
    :param include_objects_collected_by_major_gc: *(Optional)*
     By default, the sampling heap profiler reports only objects
     which are still alive when the profile is returned
     via getSamplingProfile or stopSampling, which is useful
     for determining what functions contribute the most to steady-state
     memory usage. This flag instructs the sampling heap profiler to also
     include information about objects discarded by major GC,
     which will show which functions cause large temporary memory usage
     or long GC pauses.
    :param include_objects_collected_by_minor_gc: *(Optional)*
     By default, the sampling heap profiler reports only objects
     which are still alive when the profile is returned via getSamplingProfile
     or stopSampling, which is useful for determining what functions contribute
     the most to steady-state memory usage.
     This flag instructs the sampling heap profiler to also include information
     about objects discarded by minor GC, which is useful when tuning a
     latency-sensitive application for minimal GC activity.
    NZsamplingIntervalZ includeObjectsCollectedByMajorGCZ includeObjectsCollectedByMinorGCzHeapProfiler.startSamplingr@   ©r2   )rS   rT   rU   rB   rC   r   r   r   r   Ústart_samplingÎ   s    ÿÿþrW   )Útrack_allocationsr   c                 c  s*   t ƒ }| dur| |d< d|dœ}|V }dS )z0
    :param track_allocations: *(Optional)*
    NZtrackAllocationsz%HeapProfiler.startTrackingHeapObjectsr@   rV   )rX   rB   rC   r   r   r   r   Ústart_tracking_heap_objectsü   s    þrY   c                  c  s   ddi} | V }t  | d¡¡S )z3
    :returns: Recorded sampling heap profile.
    rA   zHeapProfiler.stopSamplingrO   rP   rE   r   r   r   Ústop_sampling  s    ÿrZ   )Úreport_progressÚtreat_global_objects_as_rootsÚcapture_numeric_valueÚexpose_internalsr   c                 c  sZ   t ƒ }| dur| |d< |dur&||d< |dur6||d< |durF||d< d|dœ}|V }dS )a  
    :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: **(DEPRECATED)** *(Optional)*
     Deprecated in favor of ``exposeInternals``.
    :param capture_numeric_value: *(Optional)*
     If true, numerical values are included in the snapshot
    :param expose_internals: **(EXPERIMENTAL)** *(Optional)*
     If true, exposes internals of the snapshot.
    NÚreportProgressÚtreatGlobalObjectsAsRootsÚcaptureNumericValueÚexposeInternalsz$HeapProfiler.stopTrackingHeapObjectsr@   rV   ©r[   r\   r]   r^   rB   rC   r   r   r   r   Ústop_tracking_heap_objects  s    þrd   c                 c  sZ   t ƒ }| dur| |d< |dur&||d< |dur6||d< |durF||d< d|dœ}|V }dS )a/  
    :param report_progress: *(Optional)*
     If true 'reportHeapSnapshotProgress' events will be generated
     while snapshot is being taken.
    :param treat_global_objects_as_roots: **(DEPRECATED)** *(Optional)*
     If true, a raw snapshot without artificial roots will be generated.
     Deprecated in favor of ``exposeInternals``.
    :param capture_numeric_value: *(Optional)*
    If true, numerical values are included in the snapshot.
    :param expose_internals: **(EXPERIMENTAL)** *(Optional)*
    If true, exposes internals of the snapshot.
    Nr_   r`   ra   rb   zHeapProfiler.takeHeapSnapshotr@   rV   rc   r   r   r   Útake_heap_snapshot:  s    þre   z!HeapProfiler.addHeapSnapshotChunkc                   @  s*   e Zd ZU ded< edd dœdd„ƒZdS )ÚAddHeapSnapshotChunkr	   Úchunkr   r   c                 C  s   | t | d¡ƒd�S )Nrg   )rg   )r	   r4   r   r   r   r   r   a  s    zAddHeapSnapshotChunk.from_jsonN©r   r   r   r6   r    r   r   r   r   r   rf   \  s   
rf   zHeapProfiler.heapStatsUpdatec                   @  s.   e Zd ZU dZded< edd dœdd„ƒZdS )	ÚHeapStatsUpdatezo
    If heap objects tracking has been started then backend
    may send update for one or more fragments.
    ztyping.List[int]Ústats_updater   r   c                 C  s   | dd„ |d D ƒd�S )Nc                 S  s   g | ]}t |ƒ‘qS r   )r&   r-   r   r   r   r0   u  r1   z-HeapStatsUpdate.from_json.<locals>.<listcomp>ZstatsUpdate)rj   r   r   r   r   r   r   s  s    zHeapStatsUpdate.from_jsonN©r   r   r   r   r6   r    r   r   r   r   r   ri   f  s   
ri   zHeapProfiler.lastSeenObjectIdc                   @  s6   e Zd ZU dZded< ded< edd 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   c                 C  s    | t | d¡ƒt| d¡ƒd�S )NZlastSeenObjectIdrn   )rm   rn   )r&   r4   r$   r   r   r   r   r   „  s    þzLastSeenObjectId.from_jsonNrk   r   r   r   r   rl   x  s
   
rl   z'HeapProfiler.reportHeapSnapshotProgressc                   @  s:   e Zd ZU ded< ded< ded< edd dœdd	„ƒZd
S )ÚReportHeapSnapshotProgressr&   ÚdoneÚtotalrR   Úfinishedr   r   c                 C  s@   | t | d¡ƒt | d¡ƒ| dd ¡d ur8t| d¡ƒnd d�S )Nrp   rq   rr   )rp   rq   rr   )r&   r4   Úboolr   r   r   r   r   “  s    ÿúz$ReportHeapSnapshotProgress.from_jsonNrh   r   r   r   r   ro   Œ  s
   
ro   zHeapProfiler.resetProfilesc                   @  s    e Zd Zedd dœdd„ƒZdS )ÚResetProfilesr   r   c                 C  s   | ƒ S r   r   r   r   r   r   r   ¤  s    zResetProfiles.from_jsonN)r   r   r   r    r   r   r   r   r   rt      s   rt   )N)NNN)N)NNNN)NNNN) Ú
__future__r   ÚtypingÚdataclassesr   Úutilr   r   Ú r   r	   r   r"   r7   r<   rD   rF   rG   rH   rK   rN   rQ   rW   rY   rZ   rd   re   rf   ri   rl   ro   rt   r   r   r   r   Ú<module>   sf   # ÿ   ý/ ÿ    ü"    ü"