
    S3j8                         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mZ d dlZd Zd Zd Z G d dej$                        Zed	k(  r ej*                          yy)
    N)jittypes)
needs_blasskip_if_sysmon_unsupportedc                      t        t        j                  d d d   t        j                  d d d   f      d        } d| _        | | fS )N   c                 X    d}t        t        |             D ]  }|| |   ||   z  z  } |S )Nr   )rangelenabsumis       F/DATA/.local/lib/python3.12/site-packages/numba/tests/test_profiler.pydotz'generate_standard_dot_case.<locals>.dot   s4    s1vA1Q4!9C 
    Tr   r   float32_enable_sysmon)r   s    r   generate_standard_dot_caser      sK    %--!
emmCaC0	23 4 C8Or   c                      t        t        j                  d d d   t        j                  d d d   f      d        d_        fd} | fS )Nr   c                 j    d}t        t        |             D ]  }|| |   ||   z  z  } t        d      )Nr   zproblem with dot)r
   r   
ValueErrorr   s       r   raising_dotz.generate_raising_dot_case.<locals>.raising_dot   s=     s1vA1Q4!9C +,,r   Tc                 8    	  | |       y # t         $ r Y y w xY wN)r   )r   r   r   s     r   call_raising_dotz3generate_raising_dot_case.<locals>.call_raising_dot'   s$    	1 		s   	 	r   )r   r   s    @r   generate_raising_dot_caser      sV    %--!
emmCaC0	23- 4- "&K (((r   c                 .    t        j                  | |      S r   )npr   )r   r   s     r   np_dotr"   0   s    66!Q<r   c                   H    e Zd Zd Zed        Zed        Zed        Zd Z	y)TestProfilerc                 $    t        j                  dt         j                        }t        j                  dt         j                        }d}t        j                         }|j                          	 t        |      D ]  } |||        	 |j                          t        j                  |      j                         } fd}	 |	||j                  j                  |       ||ur |	||j                  |       yy# |j                          w xY w)zy
        Make sure the jit-compiled function shows up in the profile stats
        as a regular Python function.
           )dtype{   c                 
   t         j                  j                  |j                        |j                  |j
                  f}j                  || j                         | j                  |   }j                  |d d ||f       y )N   )	ospathbasenameco_filenameco_firstlinenoco_nameassertInstatsassertEqual)r2   coden_callsexpected_key
func_statsselfs        r   check_stats_for_keyz<TestProfiler.check_profiler_dot.<locals>.check_stats_for_keyG   so    GG,,T-=-=> // LLL
 MM,4\2JZ^gw-?@r   N)r!   aranger   profilerProfileenabler
   disablepstatsStats
strip_dirspy_func__code__)
r8   callercfuncr   r   r5   p_r2   r9   s
   `         r   check_profiler_dotzTestProfiler.check_profiler_dot6   s    
 IIb

+IIb

+	
	7^q! $ IIKQ**,		A 	E5==#9#97C v@ % IIKs   3C= =Dc                 B    t               \  }}| j                  ||       y r   )r   rH   )r8   r   rG   s      r   test_profilerzTestProfiler.test_profilerY   s    +-QS)r   c                 B    t               \  }}| j                  ||       y r   )r   rH   )r8   r   r   s      r   "test_profiler_for_raising_functionz/TestProfiler.test_profiler_for_raising_function^   s!    (A(C%% 0+>r   c                 T    d}t        j                  t        j                  d|g       y )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r8   r4   s     r   test_profiler_np_dotz!TestProfiler.test_profiler_np_dotc   s$    & 	s~~tT:;r   c                 T    d}t        j                  t        j                  d|g       y )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()
            rN   rO   rT   s     r   test_issue_3229zTestProfiler.test_issue_3229{   s$    
 	s~~tT:;r   N)
__name__
__module____qualname__rH   r   rJ   rL   r   rU   rW    r   r   r$   r$   4   sJ    !AF  *  *  ?  ? < <.<r   r$   __main__)cProfiler;   r+   r?   rP   rR   numpyr!   numbar   r   numba.tests.supportr   r   unittestr   r   r"   TestCaser$   rX   mainr[   r   r   <module>rd      s^     	   
   F 
)*Y<8$$ Y<v zHMMO r   