
    xKg                         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 Zd Zd Z G d dej"                        Zed	k(  r ej(                          yy)
    N)jittypes)
needs_blasc                      t        t        j                  d d d   t        j                  d d d   f      d        } | | fS )N   c                 X    d}t        t        |             D ]  }|| |   ||   z  z  } |S )Nr   )rangelenabsumis       ]/home/alanp/www/video.onchill/myenv/lib/python3.12/site-packages/numba/tests/test_profiler.pydotz'generate_standard_dot_case.<locals>.dot   s4    s1vA1Q4!9C 
    r   r   float32)r   s    r   generate_standard_dot_caser      sC    %--!
emmCaC0	23 4 8Or   c                      t        t        j                  d d d   t        j                  d d d   f      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   c                 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      sL    %--!
emmCaC0	23- 4- (((r   c                 .    t        j                  | |      S r   )npr   )r   r   s     r   np_dotr    .   s    66!Q<r   c                   4    e Zd Zd Zd Z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)r0   coden_callsexpected_key
func_statsselfs        r   check_stats_for_keyz<TestProfiler.check_profiler_dot.<locals>.check_stats_for_keyE   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__)
r6   callercfuncr   r   r3   p_r0   r7   s
   `         r   check_profiler_dotzTestProfiler.check_profiler_dot4   s    
 IIb

+IIb

+	
	7^q! $ IIKQ**,		A 	E5==#9#97C v@ % IIKs   3C= =Dc                 B    t               \  }}| j                  ||       y r   )r   rF   )r6   r   rE   s      r   test_profilerzTestProfiler.test_profilerW   s    +-QS)r   c                 B    t               \  }}| j                  ||       y r   )r   rF   )r6   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r6   r2   s     r   test_profiler_np_dotz!TestProfiler.test_profiler_np_dot_   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()
            rL   rM   rR   s     r   test_issue_3229zTestProfiler.test_issue_3229w   s$    
 	s~~tT:;r   N)	__name__
__module____qualname__rF   rH   rJ   r   rS   rU    r   r   r"   r"   2   s,    !AF*? < <.<r   r"   __main__)cProfiler9   r)   r=   rN   rP   numpyr   numbar   r   numba.tests.supportr   unittestr   r   r    TestCaser"   rV   mainrY   r   r   <module>rb      s^     	   
   * 	)(W<8$$ W<r zHMMO r   