
    Pi                         d dl Z d dlZd dlZddlmZmZmZ ddlmZ d Z	d Z
d Zd Zd	 Zd
 Zedk    r e             dS dS )    N   )startfinalize_select_backend)set_command_linec            	      L   t          j        ddt           j                  } |                     ddt          d           |                     dd	t          d
d g d           |                     ddt          ddddg           |                     ddt          dd            |                     ddt          ddddg           |                     ddt          dd d dg           |                     dt           j        d !           |                                 }||j        fS )"NzBThe proton command utility for profiling scripts and pytest tests.z
    proton [options] script.py [script_args] [script_options]
    proton [options] pytest [pytest_args] [script_options]
    python -m triton.profiler.proton [options] script.py [script_args] [script_options]
)descriptionusageformatter_classz-nz--namezName of the profiling session)typehelpz-bz	--backendzProfiling backend)cupti	roctracerinstrumentation)r   r   defaultchoicesz-cz	--contextzProfiling contextshadowpythonz-mz--modezProfiling mode)r   r   r   z-dz--datazProfiling datatreetracez-kz--hookzProfiling hooklaunchtarget_argszSubcommand and its arguments)nargsr   )argparseArgumentParserRawTextHelpFormatteradd_argumentstr	REMAINDER
parse_argsr   )parserargss     n/var/www/development/aibuddy-work/election-extract/venv/lib/python3.11/site-packages/triton/profiler/proton.pyparse_argumentsr$      sc   $X a 24 4 4F hS7VWWW
k:MW[ I I I  K K K
k:MW_!)8 4  6 6 6
hS7GQUVVV
hS7GQWbhjqarsss
hS7GQU`dfn_oppp
X-?FdeeeD!!!    c                 H    t           j                            |           dk    S )Npytest)ospathbasename)scripts    r#   	is_pytestr,      s    7F##x//r%   c                    t           j                            |           }ddd|dt          t          j        t          i}t          j        }| g|z   t          _        t          j                            t           j                            |                     	 t          |d          5 }t          |                                |d          }d d d            n# 1 swxY w Y   t          ||           n=# t          $ r0}t          d|            t	          j        d           Y d }~nd }~ww xY w|t          _        d S # |t          _        w xY w)	N__name____main____file____builtins__rbexecz.An error occurred while executing the script: r   )r(   r)   abspathr1   sysr.   argvappenddirnameopencompilereadr3   	Exceptionprintexit)r+   r"   script_pathclean_globalsoriginal_argvfilecodees           r#   execute_as_mainrE       sl   '//&))K 	JKc	M HMx$CHHOOBGOOK00111!+t$$ 	=499;;V<<D	= 	= 	= 	= 	= 	= 	= 	= 	= 	= 	= 	= 	= 	= 	=T=!!!!   BqBBCCC !=    sT   C3 '$CC3 CC3 CC3 2D> 3
D-=&D(#D> (D--D> >Ec                     t                       | d         }t          |           dk    r
| dd          ng }t          |          rdd l}|                    |           d S t          ||           d S )Nr   r   )r   lenr,   r'   mainrE   )r   r+   script_argsr'   s       r#   do_setup_and_executerJ   ;   s    ^F%(%5%5%9%9+abb//rK -K     ,,,,,r%   c                     | j         r| j         nt                      }t          | j        | j        | j        || j                   t          |           t                       d S )N)contextdatabackendhook)	rN   r   r   namerL   rM   rO   rJ   r   )r"   r   rN   s      r#   run_profilingrQ   H   sX    "lAdll0A0AG	$)T\	7QUQZ[[[[%%%JJJJJr%   c                  H    t                      \  } }t          | |           d S )N)r$   rQ   )r"   r   s     r#   rH   rH   R   s(    '))D+$$$$$$r%   r/   )r   r5   r(   profiler   r   r   flagsr   r$   r,   rE   rJ   rQ   rH   r.    r%   r#   <module>rV      s     



 				 5 5 5 5 5 5 5 5 5 5 # # # # # #" " "(0 0 0! ! !6
- 
- 
-  % % %
 zDFFFFF r%   