ó
ç™xTc           @   s—   d  d l  m Z d  d l Z d  d l Z d d d „  ƒ  YZ d d d „  ƒ  YZ d d d „  ƒ  YZ d	 e f d
 „  ƒ  YZ e ƒ  Z	 d d d „  ƒ  YZ
 d S(   iÿÿÿÿ(   t   divisionNt   Timerc           B   s)   e  Z d  Z d „  Z d „  Z d „  Z RS(   s“   While the class instance is in scope it accumulates CPU and wall clock
     elapsed time.  A report is printed when the instances goes out of scopec         C   s7   t  j ƒ  |  _ t  j  ƒ  |  _ | |  _ d |  j GHd  S(   Ns   start timing %s(   t   timet   clockt   startt   start_elt   message(   t   selfR   (    (    sG   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/libtbx/development/timers.pyt   __init__   s    	c         C   s   t  j ƒ  |  j S(   N(   R   R   R   (   R   (    (    sG   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/libtbx/development/timers.pyt   tick   s    c         C   sK   t  j ƒ  |  _ t  j  ƒ  |  _ d |  j |  j |  j |  j |  j f GHd  S(   Ns)   time for %s: CPU, %8.3fs; elapsed, %8.3fs(   R   R   t   endt   end_elR   R   R   (   R   (    (    sG   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/libtbx/development/timers.pyt   __del__   s    (   t   __name__t
   __module__t   __doc__R   R	   R   (    (    (    sG   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/libtbx/development/timers.pyR      s   		t   DebuggingTimerc           B   s   e  Z d  d „ Z d „  Z RS(   t   ac         C   sy   t  j ƒ  |  _ t  j  ƒ  |  _ | |  _ t | | ƒ |  _ t j |  _	 t j
 |  _ |  j t _ |  j t _
 d |  j GHd  S(   Ns   start timing %s(   R   R   R   R   R   t   opent   kt   syst   stdoutt   current_outt   stderrt   current_err(   R   R   t   filenamet   filemode(    (    sG   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/libtbx/development/timers.pyR      s    	c         C   s}   t  j ƒ  |  _ t  j  ƒ  |  _ d |  j |  j |  j |  j |  j f GH|  j t _	 |  j
 t _ |  j j ƒ  |  j j ƒ  d  S(   Ns)   time for %s: CPU, %8.3fs; elapsed, %8.3fs(   R   R   R
   R   R   R   R   R   R   R   R   R   R   t   flusht   close(   R   (    (    sG   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/libtbx/development/timers.pyR   #   s    &(   R   R   R   R   (    (    (    sG   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/libtbx/development/timers.pyR      s   t
   cumulativec           B   s#   e  Z d  „  Z d „  Z d „  Z RS(   c         C   s   | |  _  d |  _ d  S(   Ng        (   t   tagt   total(   R   R   (    (    sG   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/libtbx/development/timers.pyR   .   s    	c         C   s   |  j  | 7_  d  S(   N(   R   (   R   t   amt(    (    sG   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/libtbx/development/timers.pyt   add1   s    c         C   s   d G|  j  Gd G|  j GHd  S(   NR   R   (   R   R   (   R   (    (    sG   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/libtbx/development/timers.pyR   3   s    (   R   R   R   R!   R   (    (    (    sG   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/libtbx/development/timers.pyR   -   s   		t   singleton_datac           B   s   e  Z d  „  Z RS(   c         C   s¿   t  |  j ƒ  ƒ d k r  d GHn  d } d } x_ |  D]W } d | |  | d |  | d |  | d f GH| |  | d 7} | |  | d 7} q3 Wt  |  j ƒ  ƒ d k r» d d | | f GHn  d  S(	   Ni    s   Exiting profilerg        s7   time for %30s: CPU, %8.3fs; elapsed, %8.3fs, #calls:%4di   i   s+   TOTAL    %30s: CPU, %8.3fs; elapsed, %8.3fst    (   t   lent   keys(   R   t   total_tmt   total_elt   key(    (    sG   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/libtbx/development/timers.pyR   7   s     '(   R   R   R   (    (    (    sG   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/libtbx/development/timers.pyR"   6   s   t   Profilerc           B   s    e  Z d  Z d „  Z d „  Z RS(   sÇ  Each time the class is instantiated with the same 'message' it turns on a
     timer to accumulate CPU-elapsed and wall clock-elapsed time, until
     the instance goes out of scope.  When
     the program executable goes out of scope a final report is printed,
     explaining how many instantiations took place and the total time
     accumulated.  The Profiler will separately keep track of timings that
     are instantiated with different 'message's.c         C   s+   t  j ƒ  |  _ t  j  ƒ  |  _ | |  _ d  S(   N(   R   R   R   R   R   (   R   R   (    (    sG   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/libtbx/development/timers.pyR   O   s    c         C   sÏ   t  j ƒ  |  _ t  j  ƒ  |  _ t j |  j ƒ sI d d d g t |  j <n  t |  j d c |  j |  j 7<t |  j d c |  j |  j 7<t |  j d c d 7<d |  j |  j |  j |  j |  j f GHd  S(   Ng        i    i   i   s9   individual call time for %s: CPU, %8.3fs; elapsed, %8.3fs(	   R   R   R
   R   t   timing_singletont   has_keyR   R   R   (   R   (    (    sG   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/libtbx/development/timers.pyR   T   s    !!(   R   R   R   R   R   (    (    (    sG   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/libtbx/development/timers.pyR)   G   s   	(    (    (    (    (   t
   __future__R    R   R   R   R   R   t   dictR"   R*   R)   (    (    (    sG   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/libtbx/development/timers.pyt   <module>   s   		