o
    i                     @   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	m
Z
 d dlmZ d dlZdd Zdd Zdd	 ZG d
d dejZedkrIe  dS dS )    N)jittypes)
needs_blasc                  C   s:   t tjd d d tjd d d fdd } d| _| | fS )N   c                 S   s.   d}t t| D ]}|| | ||  7 }q|S )Nr   )rangelenabsumi r   W/home/ubuntu/transcripts/venv/lib/python3.10/site-packages/numba/tests/test_profiler.pydot   s   z'generate_standard_dot_case.<locals>.dotTr   r   float32_enable_sysmon)r   r   r   r   generate_standard_dot_case   s   "
r   c                     sF   t tjd d d tjd d d fdd  d _ fdd}  | fS )Nr   c                 S   s2   d}t t| D ]}|| | ||  7 }qtd)Nr   zproblem with dot)r   r   
ValueErrorr   r   r   r   raising_dot   s   z.generate_raising_dot_case.<locals>.raising_dotTc                    s&   z | | W d S  t y   Y d S w N)r   r	   r
   r   r   r   call_raising_dot'   s
   z3generate_raising_dot_case.<locals>.call_raising_dotr   )r   r   r   r   generate_raising_dot_case   s
   "
r   c                 C   s   t | |S r   )npr   r   r   r   r   np_dot0   s   r   c                   @   s8   e Zd Zdd Zdd Zdd Zedd Zd	d
 ZdS )TestProfilerc           
         s   t jdt jd}t jdt jd}d}t }|  zt|D ]}||| qW |  n|  w t	|
 } fdd}	|	||jj| ||urT|	||j| dS dS )zy
        Make sure the jit-compiled function shows up in the profile stats
        as a regular Python function.
           )dtype{   c                    sL   t j|j|j|jf} || j | j| } |d d ||f d S )N   )	ospathbasenameco_filenameco_firstlinenoco_nameassertInstatsassertEqual)r)   coden_callsexpected_key
func_statsselfr   r   check_stats_for_keyG   s   
z<TestProfiler.check_profiler_dot.<locals>.check_stats_for_keyN)r   aranger   profilerProfileenabler   disablepstatsStats
strip_dirspy_func__code__)
r0   callercfuncr	   r
   r,   p_r)   r1   r   r/   r   check_profiler_dot6   s    zTestProfiler.check_profiler_dotc                 C   s   t  \}}| || d S r   )r   r@   )r0   r   r?   r   r   r   test_profilerY      
zTestProfiler.test_profilerc                 C   s   t  \}}| || d S r   )r   r@   )r0   r   r   r   r   r   "test_profiler_for_raising_function]   rB   z/TestProfiler.test_profiler_for_raising_functionc                 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r0   r+   r   r   r   test_profiler_np_dota   s   z!TestProfiler.test_profiler_np_dotc                 C   rD   )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()
            rE   rF   rK   r   r   r   test_issue_3229y   s   zTestProfiler.test_issue_3229N)	__name__
__module____qualname__r@   rA   rC   r   rL   rM   r   r   r   r   r   4   s    #
r   __main__)cProfiler3   r"   r7   rG   rI   numpyr   numbar   r   numba.tests.supportr   unittestr   r   r   TestCaser   rN   mainr   r   r   r   <module>   s     Y