
    Yf                        d dl mZ d dlZd dlmZmZmZ d dlmZ d dl	m
Z
 d dlmZmZ d dlmZ eeeef   Zeeeeef   Zeeeeeeeef   f   Zeeef   Z G d d	e      Zy)
    )annotationsN)AnyDictTuple)
processors)Frame)FrameRendererProcessorList)Sessionc                  L     e Zd ZdZdZdZd	 fdZd
dZddZddZ	ddZ
 xZS )PstatsRendererz
    Outputs a marshaled dict, containing processed frames in pstat format,
    suitable for processing by gprof2dot and snakeviz.
    pstatsTc                $    t        |   di | y )N )super__init__)selfkwargs	__class__s     e/var/www/highfloat_scraper/venv/lib/python3.12/site-packages/pyinstrument/renderers/pstatsrenderer.pyr   zPstatsRenderer.__init__   s    "6"    c                X    |j                   xs d|j                  xs d|j                  fS )N r   )	file_pathline_nofunction)r   frames     r   	frame_keyzPstatsRenderer.frame_key   s%    %2u}}'95>>JJr   c                   |y | j                  |      }||vrd}d}d}d}i }n||   \  }}}}}||j                  z  }||j                  z  }|j                  rY| j                  |j                        }	|	|vr	d}
d}d}d}n
||	   \  }
}}}||j                  z  }||j                  z  }|
|||f||	<   |||||f||<   |j                  D ]!  }|j
                  r| j                  ||       # y )Nr   )r   total_self_timetimeparentchildrenis_syntheticrender_frame)r   r   statskey	call_timenumber_calls
total_timecumulative_timecallers
parent_keyp_call_timep_number_callsp_total_timep_cumulative_timechilds                  r   r&   zPstatsRenderer.render_frame"   s.   =nnU#e ILJO35GLQRUJII|Z' 	e+++
5::%<<5J( !# $%!OVWaObL^\;LE111L+"-~|M^"^GJz?GTc
^^ 	0E%%!!%/	0r   c                    | j                  |j                               }i }| j                  ||       t        j                  |      j                  dd      S )Nzutf-8surrogateescape)encodingerrors)
preprocess
root_framer&   marshaldumpsdecode)r   sessionr   r'   s       r   renderzPstatsRenderer.renderM   sP     2 2 45%' }}U#**GDU*VVr   c                    t         j                  t         j                  t         j                  t         j                  t         j
                  t         j                  t         j                  gS )N)r   remove_importlibremove_tracebackhidemerge_consecutive_self_timeaggregate_repeated_calls"remove_unnecessary_self_time_nodesremove_irrelevant_nodes*remove_first_pyinstrument_frames_processor)r   s    r   default_processorsz!PstatsRenderer.default_processorsW   sK    ''++22//99..AA
 	
r   )r   r   )r   r   returnFrameKey)r   zFrame | Noner'   	StatsDictrH   None)r=   r   )rH   r
   )__name__
__module____qualname____doc__output_file_extensionoutput_is_binaryr   r   r&   r>   rG   __classcell__)r   s   @r   r   r      s2    
 %#K)0VW	
r   r   )
__future__r   r:   typingr   r   r   pyinstrumentr   pyinstrument.framer   pyinstrument.renderers.baser	   r
   pyinstrument.sessionr   strintrI   floatCallerValue
FrameValuerJ   r   r   r   r   <module>r^      s~    "  # # # $ D ( c3E3u,-5#ueT(K2G-HHI
:%&	M
] M
r   