o ?Og@sdZgdZddlZddlZddlZdddZdddZejje_ejje_Gd d d ejZ d d Z d dZ e dkr@e dSdS)zUPython interface for the 'lsprof' profiler. Compatible with the 'profile' module. )runrunctxProfileNcCstt|||SN) _pyprofile_Utilsrr) statementfilenamesortr //opt/alt/python310/lib64/python3.10/cProfile.pyrsrcCstt|||||Sr)rrrr)r globalslocalsr r r r r rsrc@sZeZdZdZdddZddZddZd d Zd d Zd dZ ddZ ddZ ddZ dS)ra`Profile(timer=None, timeunit=None, subcalls=True, builtins=True) Builds a profiler object using the specified timer function. The default timer is a fast built-in one based on real time. For custom timer functions returning integers, timeunit can be a float specifying a scale (i.e. how long each integer unit is, in seconds). rcCs$ddl}|||dSNr)pstatsStatsZ strip_dirsZ sort_stats print_stats)selfr rr r r r)szProfile.print_statscCsNddl}t|d}|||j|WddS1s wYdS)Nrwb)marshalopen create_statsdumpstats)rfilerfr r r dump_stats-s  "zProfile.dump_statscCs||dSr)disablesnapshot_statsrr r r r3s zProfile.create_statsc Cs$|}i|_i}|D](}t|j}|j}||j}|j}|j}i} | |t|j<||||| f|j|<q |D]Y}|j rt|j}|j D]K} z |t| j} Wn t yWYqCw| j}|| j}| j}| j}|| vr| |} || d7}|| d7}|| d7}|| d7}||||f| |<qCq6dS)Nr) ZgetstatsrlabelcodeZ callcountZ reccallcountZ inlinetimeZ totaltimeidZcallsKeyError) rentriesZ callersdictsentryfuncZncZccZttZctZcallersZsubentryprevr r r r7sD          zProfile.snapshot_statscCsddl}|j}||||Sr)__main____dict__r)rcmdr,dictr r r r]sz Profile.runcCs.|z t|||W||S|wr)enableexecr)rr.rrr r r rbs  zProfile.runctxcOs,|z ||i|W|S|wr)r0r)rr*argskwr r r runcallkszProfile.runcallcCs ||Sr)r0r r r r __enter__rszProfile.__enter__cGs |dSr)r)rexc_infor r r __exit__vs zProfile.__exit__N)r) __name__ __module__ __qualname____doc__rrrrrrr4r5r7r r r r rs &  rcCs$t|tr dd|fS|j|j|jfS)N~r) isinstancestr co_filenameco_firstlinenoco_name)r%r r r r${s  r$c Csddl}ddl}ddl}ddl}ddlm}d}||d}d|_|jdddd dd |jd d d ddt|j j d|jdddddd|j ddsS| | d|\}}||j dd<|jdurm|j|j|_t|dkr|jrd} |j|dd} n3|d} |jd|j| t| } t| | d} Wdn1swY| dddd} z t| | d|j|jW|Sty} zd|_| | jWYd} ~ |Sd} ~ ww| |S)Nr) OptionParserzNcProfile.py [-o output_file_path] [-s sort] [-m module | scriptfile] [arg] ...)usageFz-oz --outfileoutfilezSave stats to )desthelpdefaultz-sz--sortr z?Sort order when printing to stdout, based on pstats.Stats classr)rErFrGchoicesz-mmodule store_truezProfile a library module)rEactionrFrGr!r"z(run_module(modname, run_name='__main__')) run_modulemodnamer1r,)__file__r8 __package__ __cached__) ossysrunpyrZoptparserBZallow_interspersed_argsZ add_optionsortedrZsort_arg_dict_defaultargvZ print_usageexit parse_argsrDpathabspathlenrIrLinsertdirnameio open_codecompilereadrr BrokenPipeErrorstdouterrno)rQrRrSrrBrCparserZoptionsr2r%ZglobsZprognamefpexcr r r mainsj           rgr,)Nr) r;__all__Z_lsprofr]ZprofilerrrZProfilerrr$rgr8r r r r s    _;