U e5db@s~dddgZddlZddlZddlZdddZdddZejje_ejje_GdddejZ d d Z d d Z e d krze dS)runrunctxProfileNcCstt|||SN) _pyprofile_Utilsrr) statementfilenamesortr /usr/lib64/python3.8/cProfile.pyrscCstt|||||Sr)rrrr)r globalslocalsr r r r r rsc@s\eZdZdddZddZddZdd Zd d Zd d ZddZ de _ ddZ ddZ dS)rrcCs$ddl}|||dSNr)pstatsStatsZ strip_dirsZ sort_stats print_stats)selfr rr r r r)szProfile.print_statsc Cs8ddl}t|d}|||j|W5QRXdS)Nrwb)marshalopen create_statsdumpstats)rfilerfr r r dump_stats-s zProfile.dump_statscCs||dSr)disablesnapshot_statsrr r r r3szProfile.create_statsc Cs,|}i|_i}|D]P}t|j}|j}||j}|j}|j}i} | |t|j<||||| f|j|<q|D]}|j rlt|j}|j D]} z|t| j} Wnt k rYqYnX| j}|| j}| j}| j}|| kr| |} || d7}|| d7}|| d7}|| d7}||||f| |<qqldS)Nr) ZgetstatsrlabelcodeZ callcountZ reccallcountZ inlinetimeZ totaltimeidZcallsKeyError) rentriesZ callersdictsentryfuncZncZccZttZctZcallersZsubentryprevr r r r7s>           zProfile.snapshot_statscCsddl}|j}||||Sr)__main____dict__r)rcmdr,dictr r r r]sz Profile.runcCs(|zt|||W5|X|Sr)enablerexec)rr.rrr r r rbs  zProfile.runctxcOst|dkr|^}}}nV|s&tdnHd|krZ|d}|^}}ddl}|jdtddntdt|d|z|||WS|XdS) Nr"z:descriptor 'runcall' of 'Profile' object needs an argumentr*rz0Passing 'func' as keyword argument is deprecated) stacklevelz7runcall expected at least 1 positional argument, got %dr!)len TypeErrorpopwarningswarnDeprecationWarningr0r)argskwrr*r6r r r runcallks&     zProfile.runcallz($self, func, /, *args, **kw)cCs ||Sr)r0r r r r __enter__szProfile.__enter__cGs |dSr)r)rexc_infor r r __exit__szProfile.__exit__N)r) __name__ __module__ __qualname__rrrrrrr;__text_signature__r<r>r r r r rs & cCs(t|trdd|fS|j|j|jfSdS)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 dds| | d|\}}||j dd<|jdk r|j|j|_t|dkr|jrd} |j|dd} nR|d} |jd|j| t| } t| | d} W5QRX| dddd} zt| | d|j|jWn6tk r} zd|_| | jW5d} ~ XYnXn| |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)rLrMrNchoicesz-mmodule store_truezProfile a library module)rLactionrMrNr!r"z(run_module(modname, run_name='__main__')) run_modulemodnamer1r,)__file__r? __package__ __cached__) ossysrunpyrZoptparserIZallow_interspersed_argsZ add_optionsortedrZsort_arg_dict_defaultargvZ print_usageexit parse_argsrKpathabspathr3rPrSinsertdirnameio open_codecompilereadrr BrokenPipeErrorstdouterrno)rXrYrZrrIrJparserZoptionsr9r%ZglobsZprognamefpexcr r r mainsd           rmr,)Nr)Nr) __all__Z_lsprofrcZprofilerrr__doc__ZProfilerrr$rmr?r r r r s     o;