Server: appserver-7f0f8755-nginx-15961cad18524ec5a9db05f2a6a7e440
Current directory: /usr/lib/python2.7
Software: nginx/1.27.5
Shell Command
Create a new file
Upload file
File: profile.pyc
� ӫ[c @ s$ d Z d d l Z d d l Z d d l Z d d l Z d d l m Z d d d d g Z e d d � Z e d d � Z d � Z e e d � r� e j d � Z n d Z y+ d d l Z d � Z e d � Z d Z Wn e k r� n Xd f d � � YZ d � Z d � Z e d k r e � n d S( s Class for profiling Python code.i����N( t OptionParsert runt runctxt helpt Profilec C s] t � } y | j | � } Wn t k r/ n X| d k rL | j | � n | j | � Sd S( s Run statement under profiler optionally saving results in filename This function takes a single argument that can be passed to the "exec" statement, and an optional file name. In all cases this routine attempts to "exec" its first argument and gather profiling statistics from the execution. If no file name is present, then this function automatically prints a simple profiling report, sorted by the standard name string (file/line/function-name) that is presented in each line. N( R R t SystemExitt Nonet dump_statst print_stats( t statementt filenamet sortt prof( ( s /usr/lib/python2.7/profile.pyR 0 s c C sc t � } y | j | | | � } Wn t k r5 n X| d k rR | j | � n | j | � Sd S( s� Run statement under profiler, supplying your own globals and locals, optionally saving results in filename. statement and filename have the same semantics as profile.run N( R R R R R R ( R t globalst localsR R R ( ( s /usr/lib/python2.7/profile.pyR E s c C s d GHd GHd S( Ns2 Documentation for the profile module can be found s? in the Python Library Reference, section 'The Python Profiler'.( ( ( ( s /usr/lib/python2.7/profile.pyR W s t timesc C s | � } | d | d S( Ni i ( ( t timert t( ( s /usr/lib/python2.7/profile.pyt _get_time_times\ s i c C s t j t j � S( N( t resourcet getrusaget RUSAGE_SELF( ( ( s /usr/lib/python2.7/profile.pyt
g s c C s | � } | d | d S( Ni i ( ( R R ( ( s /usr/lib/python2.7/profile.pyt _get_time_resourceh s i c B s3 e Z d Z d Z d" d" d � Z d � Z d � Z d � Z d � Z d � Z d � Z d � Z d � Z i e d 6e d 6e d 6e d 6e d 6e d 6Z d � Z d d# d � � YZ d d$ d � � YZ d � Z d � Z d d � Z d � Z d � Z d � Z d � Z d � Z d � Z d d � Z d! � Z RS(% s Profiler class. self.cur is always a tuple. Each such tuple corresponds to a stack frame that is currently active (self.cur[-2]). The following are the definitions of its members. We use this external "parallel stack" to avoid contaminating the program that we are profiling. (old profiler used to write into the frames local dictionary!!) Derived classes can change the definition of some entries, as long as they leave [-2:] intact (frame and previous tuple). In case an internal error is detected, the -3 element is used as the function name. [ 0] = Time that needs to be charged to the parent frame's function. It is used so that a function call will not have to access the timing data for the parent frame. [ 1] = Total time spent in this frame's function, excluding time in subfunctions (this latter is tallied in cur[2]). [ 2] = Total time spent in subfunctions, excluding time executing the frame's function (this latter is tallied in cur[1]). [-3] = Name of the function that corresponds to this frame. [-2] = Actual frame that we correspond to (used to sync exception handling). [-1] = Our parent 6-tuple (corresponds to frame.f_back). Timing data for each function is stored as a 5-tuple in the dictionary self.timings[]. The index is always the name stored in self.cur[-3]. The following are the definitions of the members: [0] = The number of times this function was called, not counting direct or indirect recursion, [1] = Number of times this function appears on the stack, minus one [2] = Total time spent internal to this function [3] = Cumulative time that this function was present on the stack. In non-recursive functions, this is the total execution time from start to finish of each invocation of a function, including time spent in all subfunctions. [4] = A dictionary indicating for each function name, the number of times it was called by us. i c C s� i | _ d | _ d | _ d | _ | d k r<