U
    ,d:
                     @   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Zdd Zdd ZG dd	 d	ejZed
kre  dS )    N)jit)
needs_blasc                 C   s.   d}t t| D ]}|| | ||  7 }q|S )Nr   )rangelen)absumi r
   =/tmp/pip-unpacked-wheel-eu7e0c37/numba/tests/test_profiler.pydot   s    r   c                 C   s   t | |S N)npr   )r   r   r
   r
   r   np_dot   s    r   c                   @   s0   e Zd Zdd Zdd Zedd Zdd Zd	S )
TestProfilerc           	      C   s   t jdt jd}t jdt jd}tdd|}||| t }|  z||| W 5 |  X t	|
 }|j}tj|j|j|jf}| ||j dS )zy
        Make sure the jit-compiled function shows up in the profile stats
        as a regular Python function.
           )ZdtypeT)ZnopythonN)r   ZarangeZfloat32r   profilerZProfileenabledisablepstatsZStatsZ
strip_dirs__code__ospathbasenameco_filenameco_firstlinenoco_nameZassertInstats)	selfZpyfuncr   r   Zcfuncpr   codeZexpected_keyr
   r
   r   check_profiler_dot   s     

zTestProfiler.check_profiler_dotc                 C   s   |  t d S r   )r!   r   )r   r
   r
   r   test_profiler2   s    zTestProfiler.test_profilerc                 C   s   d}t tjd|g d S )Na  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()
            -c
subprocess
check_callsys
executabler   r    r
   r
   r   test_profiler_np_dot5   s    z!TestProfiler.test_profiler_np_dotc                 C   s   d}t tjd|g d S )Na  if 1:
            import cProfile as profiler
            p = profiler.Profile()
            p.enable()

            from numba.tests.npyufunc.test_dufunc import TestDUFunc
            t = TestDUFunc('test_npm_call')
            t.test_npm_call()

            p.disable()
            r#   r$   r)   r
   r
   r   test_issue_3229M   s    zTestProfiler.test_issue_3229N)__name__
__module____qualname__r!   r"   r   r*   r+   r
   r
   r
   r   r      s
   
r   __main__)ZcProfiler   r   r   r%   r'   Znumpyr   Znumbar   Znumba.tests.supportr   Zunittestr   r   ZTestCaser   r,   mainr
   r
   r
   r   <module>   s   I