o ö]Lbô ã@s8dZddlmZddlmZdd„ZGdd„deƒZd S) aC lsprofcalltree.py - lsprof output which is readable by kcachegrind Authors: * David Allouche 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. é)Úabsolute_importé)ÚpycompatcCs8t|tƒr dt |¡Sdt |j¡t |j¡|jfS)Nó~s%s %s:%d)Ú isinstanceÚstrrÚsysbytesÚco_nameÚ co_filenameÚco_firstlineno)Úcode©r ú:/usr/lib/python3/dist-packages/mercurial/lsprofcalltree.pyÚlabels   ýrc@s4eZdZdd„Zdd„Zdd„Zdd„Zd d „Zd S) Ú KCacheGrindcCs| ¡|_d|_dS)N)ÚgetstatsÚdataÚout_file)ÚselfÚprofilerr r rÚ__init__s  zKCacheGrind.__init__cCs2||_| d¡| ¡|jD]}| |¡qdS)Nsevents: Ticks )rÚwriteÚ_print_summaryrÚ_entry)rrÚentryr r rÚoutput#s    ÿzKCacheGrind.outputcCs<d}|jD]}t|jdƒ}t||ƒ}q|j d|¡dS)Nréès summary: %d )rÚintÚ totaltimeÚmaxrr)rÚmax_costrrr r rr*s   zKCacheGrind._print_summarycCsÒ|j}|j}t|tƒr| d¡n | dt |j¡¡| dt|ƒ¡t |j dƒ}t|tƒr9| d|¡n | d|j |f¡|j rJ|j }ng}t|tƒrTd}n|j }|D]}|  ||¡qY| d¡dS) Nsfi=~ sfi=%s sfn=%s rs0 %d ó%d %d ró )rr rrrrrr rrÚ inlinetimer ÚcallsÚ _subentry)rrrr r#r$ÚlinenoÚsubentryr r rr1s&    zKCacheGrind._entrycCs”|j}|j}| dt|ƒ¡t|tƒr"| d¡| d|j¡n| dt |j ¡¡| d|j|j f¡t |j dƒ}| d||f¡dS)Nscfn=%s scfi=~ s calls=%d 0 scfi=%s s calls=%d %d rr!) rr rrrrÚ callcountrrr r rr)rr&r'rr rr r rr%Rs  ÿzKCacheGrind._subentryN)Ú__name__Ú __module__Ú __qualname__rrrrr%r r r rrs  !rN)Ú__doc__Ú __future__rÚrrÚobjectrr r r rÚs