U
    iâËdR
  ã                   @   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mZ d dlZdd„ Zdd„ ZG dd	„ d	ejƒZed
kr†e ¡  dS )é    N)Újit)Ú
needs_blasÚexpected_failure_py311c                 C   s.   d}t t| ƒƒD ]}|| | ||  7 }q|S )Nr   )ÚrangeÚlen)ÚaÚbÚsumÚi© r   úR/home/sam/Atlas/atlas_env/lib/python3.8/site-packages/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(   Únumpyr   Znumbar   Znumba.tests.supportr   r   Zunittestr   r   ZTestCaser   r-   Úmainr   r   r   r   Ú<module>   s   I