o
    8ή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Zdd Zdd ZG dd	 d	ejZed
krCe  dS 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-target-vg8gfxp4/lib/python/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 |  n|  w 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.
           )dtypeT)nopythonN)r   arangefloat32r   profilerProfileenabledisablepstatsStats
strip_dirs__code__ospathbasenameco_filenameco_firstlinenoco_nameassertInstats)	selfpyfuncr   r   cfuncpr%   code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      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   r.   )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/   r0   r5   r
   r
   r   test_issue_3229M   s   zTestProfiler.test_issue_3229N)__name__
__module____qualname__r,   r-   r   r6   r7   r
   r
   r
   r   r      s    
r   __main__)cProfiler   r   r   r1   r3   numpyr   numbar   numba.tests.supportr   unittestr   r   TestCaser   r8   mainr
   r
   r
   r   <module>   s    I