ó
å™xTc           @   s*   d  d l  m Z d e f d „  ƒ  YZ d S(   iÿÿÿÿ(   t   divisiont   easy_profilec           B   s#   e  Z d  Z d d „ Z d „  Z RS(   s&    cProfile.Profile easy-to-use wrapper i   c         C   sN   d d l  } | j ƒ  |  _ | |  _ | | | |  _ |  _ |  _ | |  _ d S(   sž    Profiling of the callable func.
    file_name, func_name, line shall tell where func is defined.
    runs is the number of calls which will be performed
    iÿÿÿÿN(   t   cProfilet   Profilet   proft   funct	   file_namet	   func_namet   linet   runs(   t   selfR   R   R   R   R	   R   (    (    sA   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/libtbx/easy_profile.pyt   __init__   s
    	c         O   s  x0 t  |  j ƒ D] } |  j j |  j | | Ž q W|  j j ƒ  x¦ |  j j j ƒ  D]Ž \ \ } } } } |  j d k	 r’ | j
 |  j ƒ s’ qS q’ n  |  j d k	 r¹ | |  j k r¹ qS q¹ n  |  j d k	 rà | |  j k rà qS qà n  PqS Wd S| d } | d }	 |	 | }
 |
 S(   s1    Time spent per-call in self.func(*args, **kwds) i    i   N(   t   xrangeR	   R   t   runcallR   t   create_statst   statst	   iteritemsR   t   Nonet   endswithR   R   (   R
   t   argst   kwdst   iR   R   R   t   datat   callst
   cumulativet   t(    (    sA   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/libtbx/easy_profile.pyt   time   s&    ( 	 	 	


(   t   __name__t
   __module__t   __doc__R   R   (    (    (    sA   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/libtbx/easy_profile.pyR      s   N(   t
   __future__R    t   objectR   (    (    (    sA   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/libtbx/easy_profile.pyt   <module>   s   