ó
čžbc           @   s   d  Z  d d d d g Z d d l Z d d d  Z d d d  Z d	   Z d e j f d
     YZ d   Z	 d   Z
 e d k r e
   n  d S(   sU   Python interface for the 'lsprof' profiler.
   Compatible with the 'profile' module.
t   runt   runctxt   helpt   Profilei˙˙˙˙Nc         C   sm   t    } d } z+ y | j |   } Wn t k
 r8 n XWd | d k	 rY | j |  n | j |  } X| 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   t   NoneR    t
   SystemExitt
   dump_statst   print_stats(   t	   statementt   filenamet   sortt   proft   result(    (    s   /usr/lib/python2.7/cProfile.pyR       s    	c         C   ss   t    } d } z1 y | j |  | |  } Wn t k
 r> n XWd | d k	 r_ | j |  n | j |  } X| 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   R   (    (    s   /usr/lib/python2.7/cProfile.pyR   '   s    	c           C   s   d GHd GHd  S(   Ns<   Documentation for the profile/cProfile modules can be found s?   in the Python Library Reference, section 'The Python Profiler'.(    (    (    (    s   /usr/lib/python2.7/cProfile.pyR   <   s    c           B   sP   e  Z d  Z d d  Z d   Z d   Z d   Z d   Z d   Z d   Z	 RS(	   s`  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).
    i˙˙˙˙c         C   s2   d d  l  } | j |   j   j |  j   d  S(   Ni˙˙˙˙(   t   pstatst   Statst
   strip_dirst
   sort_statsR   (   t   selfR
   R   (    (    s   /usr/lib/python2.7/cProfile.pyR   O   s    c         C   sF   d d  l  } t | d  } |  j   | j |  j |  | j   d  S(   Ni˙˙˙˙t   wb(   t   marshalt   opent   create_statst   dumpt   statst   close(   R   t   fileR   t   f(    (    s   /usr/lib/python2.7/cProfile.pyR   S   s
    
c         C   s   |  j    |  j   d  S(   N(   t   disablet   snapshot_stats(   R   (    (    s   /usr/lib/python2.7/cProfile.pyR   Z   s    
c         C   s  |  j    } i  |  _ i  } xz | D]r } t | j  } | j } | | j } | j } | j } i  }	 |	 | t | j  <| | | | |	 f |  j | <q" Wxú | D]ň } | j	 r t | j  } xŃ | j	 D]Ă }
 y | t |
 j  }	 Wn t
 k
 rú qÇ n X|
 j } | |
 j } |
 j } |
 j } | |	 k rt|	 | } | | d 7} | | d 7} | | d 7} | | d 7} n  | | | | f |	 | <qÇ Wq q Wd  S(   Ni    i   i   i   (   t   getstatsR   t   labelt   codet	   callcountt   reccallcountt
   inlinetimet	   totaltimet   idt   callst   KeyError(   R   t   entriest   callersdictst   entryt   funct   nct   cct   ttt   ctt   callerst   subentryt   prev(    (    s   /usr/lib/python2.7/cProfile.pyR   ^   s>    				 				
c         C   s(   d d  l  } | j } |  j | | |  S(   Ni˙˙˙˙(   t   __main__t   __dict__R   (   R   t   cmdR4   t   dict(    (    s   /usr/lib/python2.7/cProfile.pyR       s    	c         B   s*   |  j    z | | | UWd  |  j   X|  S(   N(   t   enableR   (   R   R6   R   R   (    (    s   /usr/lib/python2.7/cProfile.pyR      s
    
c         O   s-   |  j    z | | |   SWd  |  j   Xd  S(   N(   R8   R   (   R   R,   t   argst   kw(    (    s   /usr/lib/python2.7/cProfile.pyt   runcall   s    
(
   t   __name__t
   __module__t   __doc__R   R   R   R   R    R   R;   (    (    (    s   /usr/lib/python2.7/cProfile.pyR   B   s   			&			c         C   s6   t  |  t  r d d |  f S|  j |  j |  j f Sd  S(   Nt   ~i    (   t
   isinstancet   strt   co_filenamet   co_firstlinenot   co_name(   R!   (    (    s   /usr/lib/python2.7/cProfile.pyR       s    c          C   s  d d  l  }  d d  l } d d  l } d d l m } d } | d |  } t | _ | j d d d d d	 d
 d d  | j d d d d d	 d d d d t	 | j
 j  | j d sĎ | j   | j d  n  | j   \ } } | | j (t |  d k r| d } | j j d |  j j |   t | d   }	 t |	 j   | d  }
 Wd  QXi | d 6d d 6d  d 6} t |
 | d  | j | j  n
 | j   | S(   Ni˙˙˙˙(   t   OptionParsers@   cProfile.py [-o output_file_path] [-s sort] scriptfile [arg] ...t   usages   -os	   --outfilet   destt   outfileR   s   Save stats to <outfile>t   defaults   -ss   --sortR
   s?   Sort order when printing to stdout, based on pstats.Stats classt   choicesi   i   i    t   rbt   exect   __file__R4   R<   t   __package__(   t   ost   sysR   t   optparseRE   t   Falset   allow_interspersed_argst
   add_optionR   t   sortedR   t   sort_arg_dict_defaultt   argvt   print_usaget   exitt
   parse_argst   lent   patht   insertt   dirnameR   t   compilet   readR   RH   R
   (   RO   RP   R   RE   RF   t   parsert   optionsR9   t   prognamet   fpR!   t   globs(    (    s   /usr/lib/python2.7/cProfile.pyt   mainŁ   s8    $	




R4   (   R>   t   __all__t   _lsprofR   R    R   R   t   ProfilerR   R    Rf   R<   (    (    (    s   /usr/lib/python2.7/cProfile.pyt   <module>   s   	Y		$