ó
\K]c           @   sÀ   d  d l  Z d  d l Z d  d l Z d  d l Z d  d l Z d  d l Z d  d l m	 Z	 d  d l m
 Z d d l m Z d „  Z d „  Z d e j f d	 „  ƒ  YZ e d
 k r¼ e j ƒ  n  d S(   iÿÿÿÿN(   t   jit(   t   unittest_supporti   (   t
   needs_blasc         C   s=   d } x0 t  t |  ƒ ƒ D] } | |  | | | 7} q W| S(   Ni    (   t   ranget   len(   t   at   bt   sumt   i(    (    s8   lib/python2.7/site-packages/numba/tests/test_profiler.pyt   dot   s    c         C   s   t  j |  | ƒ S(   N(   t   npR	   (   R   R   (    (    s8   lib/python2.7/site-packages/numba/tests/test_profiler.pyt   np_dot   s    t   TestProfilerc           B   s)   e  Z d  „  Z d „  Z e d „  ƒ Z RS(   c   	      C   sà   t  j d d t  j ƒ} t  j d d t  j ƒ} t d t ƒ | ƒ } | | | ƒ t j ƒ  } | j ƒ  z | | | ƒ Wd | j ƒ  Xt	 j
 | ƒ j ƒ  } | j } t j j | j ƒ | j | j f } |  j | | j ƒ d S(   sy   
        Make sure the jit-compiled function shows up in the profile stats
        as a regular Python function.
        i   t   dtypet   nopythonN(   R
   t   aranget   float32R    t   Truet   profilert   Profilet   enablet   disablet   pstatst   Statst
   strip_dirst   __code__t   ost   patht   basenamet   co_filenamet   co_firstlinenot   co_namet   assertInt   stats(	   t   selft   pyfuncR   R   t   cfunct   pR!   t   codet   expected_key(    (    s8   lib/python2.7/site-packages/numba/tests/test_profiler.pyt   check_profiler_dot   s    
	c         C   s   |  j  t ƒ d  S(   N(   R(   R	   (   R"   (    (    s8   lib/python2.7/site-packages/numba/tests/test_profiler.pyt   test_profiler2   s    c         C   s#   d } t  j t j d | g ƒ d  S(   NsÊ  if 1:
            import cProfile as profiler

            import numpy as np

            from numba import jit
            from numba.tests.test_profiler import np_dot

            cfunc = jit(nopython=True)(np_dot)

            a = np.arange(16, dtype=np.float32)
            b = np.arange(16, dtype=np.float32)

            p = profiler.Profile()
            p.enable()
            cfunc(a, b)
            cfunc(a, b)
            p.disable()
            s   -c(   t
   subprocesst
   check_callt   syst
   executable(   R"   R&   (    (    s8   lib/python2.7/site-packages/numba/tests/test_profiler.pyt   test_profiler_np_dot5   s    (   t   __name__t
   __module__R(   R)   R   R.   (    (    (    s8   lib/python2.7/site-packages/numba/tests/test_profiler.pyR      s   		t   __main__(   t   cProfileR   R   R   R*   R,   t   numpyR
   t   numbaR    R   t   unittestt   test_linalgR   R	   R   t   TestCaseR   R/   t   main(    (    (    s8   lib/python2.7/site-packages/numba/tests/test_profiler.pyt   <module>   s   		6