
    q&f
                     .    d Z ddlmZ d Z G d d      Zy)aC  
lsprofcalltree.py - lsprof output which is readable by kcachegrind

Authors:
    * David Allouche <david <at> allouche.net>
    * Jp Calderone & Itamar Shtull-Trauring
    * Johan Dahlin

This software may be used and distributed according to the terms
of the GNU General Public License, incorporated herein by reference.
   )pycompatc                     t        | t              rdt        j                  |       z   S dt        j                  | j                        t        j                  | j
                        | j                  fz  S )N   ~s   %s %s:%d)
isinstancestrr   sysbytesco_nameco_filenameco_firstlineno)codes    :/usr/lib/python3/dist-packages/mercurial/lsprofcalltree.pylabelr      sc    $h''---dll+d../
 
 	
    c                   *    e Zd Zd Zd Zd Zd Zd Zy)KCacheGrindc                 <    |j                         | _        d | _        y )N)getstatsdataout_file)selfprofilers     r   __init__zKCacheGrind.__init__   s    %%'	r   c                     || _         |j                  d       | j                          | j                  D ]  }| j	                  |        y )Ns   events: Ticks
)r   write_print_summaryr   _entry)r   r   entrys      r   outputzKCacheGrind.output"   sA     )*YY 	EKK	r   c                     d}| j                   D ]&  }t        |j                  dz        }t        ||      }( | j                  j                  d|z         y )N      s   summary: %d
)r   int	totaltimemaxr   r   )r   max_costr   r#   s       r   r   zKCacheGrind._print_summary)   sS    YY 	0EEOOd23I8Y/H	0 	,x78r   c                    | j                   }|j                  }t        |t              r|j	                  d       n1|j	                  dt        j                  |j                        z         |j	                  dt        |      z         t        |j                  dz        }t        |t              r|j	                  d|z         n |j	                  d|j                  |fz         |j                  r|j                  }ng }t        |t              rd}n|j                  }|D ]  }| j                  ||        |j	                  d       y )	Ns   fi=~
s   fi=%s
s   fn=%s
r!   s   0 %d
   %d %d
r       
)r   r   r   r   r   r   r   r
   r   r"   
inlinetimer   calls	_subentry)r   r   r   r   r)   r*   linenosubentrys           r   r   zKCacheGrind._entry0   s	   ==zzdC NN9%NN:(9(9$:J:J(KKLzE$K/0))D01
dC NN9z12NN:)<)<j(IIJ ;;KKEEdC F((F 	-HNN68,	- 	ur   c                     | j                   }|j                  }|j                  dt        |      z         t	        |t
              r0|j                  d       |j                  d|j                  z         n[|j                  dt        j                  |j                        z         |j                  d|j                  |j                  fz         t        |j                  dz        }|j                  d||fz         y )Ns   cfn=%s
s   cfi=~
s   calls=%d 0
s   cfi=%s
s   calls=%d %d
r!   r'   )r   r   r   r   r   r   	callcountr   r   r
   r   r"   r#   )r   r,   r-   r   r   r#   s         r   r+   zKCacheGrind._subentryQ   s    ==}}{U4[01dC NN:&NN?X-?-??@NN;):):4;K;K)LLMNN H$6$68K8K#LL **T12	zVY$778r   N)__name__
__module____qualname__r   r   r   r   r+    r   r   r   r      s    9B9r   r   N)__doc__ r   r   r   r3   r   r   <module>r6      s    
 	
B9 B9r   