+
    Bi#                        ^ RI t ^ RIt^ RIt^ RIt^ RIHt ^ RIHt ^ RIH	t	H
t
HtHt ^ RIHtHt ^ RIt^ RIHtHt ^ RIHtHt  ! R R	]P.                  4      tR
 t]R 4       tR t/ tR]R&   R]R&   R]R&   ]R8X  d
   ]! 4        R# R# )    N)unified_diff)StringIO)TESTFNunlinktemp_dir
change_cwd)contextmanagerredirect_stdout)testfunctimer)assert_python_failureassert_python_okc                      a  ] tR t^t o ]P
                  t]t. ROtRt	R t
R t]R 4       tR tR tR tR tR	 tR
 tR tRtV tR# )ProfileTestz:0(max)c                $    \        \        4       R # N)r   r   selfs   &(/usr/lib/python3.14/test/test_profile.pytearDownProfileTest.tearDown   s	    v    c                    \         # r   )_ProfileOutputr   s   &r   get_expected_outputProfileTest.get_expected_output   s    r   c                   . pV P                  \        R 4      p\        4       pVP                  R\        4       \	        4       4       VP                  \        4       V,
          4       V P                   F  p\        4       p\        P                  ! W%R7      pVP                  4       P                  R4       \        Wd4      ! 4        VP                  4       P                  4       p\        P                   P#                  R^4      ^,          pV U	u. uF  qV	9   g   K  V	P%                  4       NK  	  pp	VP                  RP'                  V4      4       K  	  V# u up	i )MbP?
testfunc()streamstdname.
)profilerclassr   runctxglobalslocalsappendmethodnamesr   pstatsStats
strip_dirs
sort_statsgetattrgetvalue
splitlinesr   
__module__rsplitrstripjoin)
clsresultsprofstart_timer
methodnamesstatsoutputmod_namelines
   &         r   do_profilingProfileTest.do_profiling   s     .gL')VX6uw,-//J
ALL0E)))4E&(ZZ\,,.F**11#q9!<H 17Kd:JmdkkmFKNN499V,- *  Ls   EEc           	        V P                  4       pV P                  4       pV P                  V^ ,          R4       . p\        V P                  4       F  w  rEW%,          pW^,           ,          pWg8w  g   K$  VP                  RV RV P                  P                   R24       VP                  \        VP                  R4      VP                  R4      RR7      4       K  	  V'       d#   V P                  RP                  V4      4       R# R# )	r   i  z
Stats.z output for z does not fit expectation:r$    )linetermN)r@   r   assertEqual	enumerater*   r)   r%   __name__extendr   splitfailr5   )r   r7   expectedrJ   imethodabs   &       r   test_cprofileProfileTest.test_cprofile3   s    ##%++-T*"4#3#34IA A!Avhvhl#11::; <99 : L%') * 5 IIdiio& r   c           	     l   . ROpV F  p\        4       pV P                  \        R4      pVP                  V\	        4       \        4       4       \        P                  ! WCR7      pVP                  4        VP                  4       pV P                  V P                  VRP                  W&4      4       K  	  R# )max([0])r   r    z&Profiling {0!r} didn't report max:
{1}N)rS   zmax([0], key=int)zmax([0], **dict(key=int))zmax(*([0],))zmax(*([0],), key=int)zmax(*([0],), **dict(key=int)))r   r%   r   r&   r'   r(   r+   r,   print_statsr0   assertInexpected_max_outputformat)r   stmtsstmtr;   r8   r<   ress   &      r   test_calling_conventions$ProfileTest.test_calling_conventionsD   s    
 D
A%%eU3DKKgi2LL0E**,CMM$22C9@@KM r   c                >   \        4       ;_uu_ 4        V P                  P                  R 4       RRR4       V P                  P                  R \        R7       V P	                  \
        P                  P                  \        4      4       R#   + '       g   i     Le; i)int('1')Nfilename)silentprofilermodulerunr   
assertTrueospathexistsr   s   &r   test_runProfileTest.test_runY   s\    XX##J/ 
V<v./ Xs   BB	c                    \        \        4       4      ;_uu_ 4       pV P                  P                  R RR7       RRR4       V P	                  RXP                  4       4       R#   + '       g   i     L2; i)r^   )sortNz(Ordered by: internal time, standard name)tottimer"   )r
   r   rb   rc   rU   r0   )r   fs   & r   test_run_with_sort_by_values(ProfileTest.test_run_with_sort_by_values_   sN    XZ((A##J5K#L )@!**,O )(s   A$$A4	c                   \        4       ;_uu_ 4        V P                  P                  R \        4       \	        4       4       RRR4       V P                  P                  R \        4       \	        4       \
        R7       V P                  \        P                  P                  \
        4      4       R#   + '       g   i     Lw; i)r   Nr_   )
ra   rb   r&   r'   r(   r   rd   re   rf   rg   r   s   &r   test_runctxProfileTest.test_runctxd   sq    XX&&|WYI ""<FH+1 	# 	3v./	 Xs   .B00C 	c                    \        R V P                  P                  R 4       \        R V P                  P                  R R4       \        R V P                  P                  R RRR4       R# )-mrandom_module_xyztimeitz-n1N)r   rb   rG   r   r   s   &r   test_run_profile_as_module&ProfileTest.test_run_profile_as_modulek   s]    dD$7$7$@$@$G 	dD$7$7$@$@"$7	9 	t22;;xs	4r   c                   \        4       ;_uu_ 4       p\        V4      ;_uu_ 4        \        P                  ! R 4       \	        RRRR7      ;_uu_ 4       pVP                  R4       RRR4       \        RV P                  P                  RR	R4       V P                  \        P                  P                  R	4      4       RRR4       RRR4       R#   + '       g   i     Ls; i  + '       g   i     L-; i  + '       g   i     R# ; i)
destzdemo.pywzutf-8)encodingzimport os; os.chdir("dest")Nrt   z-oz
out.pstats)r   r   re   mkdiropenwriter   rb   rG   rd   rf   rg   )r   tmpdirrm   s   &  r   (test_output_file_when_changing_directory4ProfileTest.test_output_file_when_changing_directoryw   s    ZZ6:f#5#5HHViw77156 8 d))22l OOBGGNN<89 $6ZZ77 $6#5ZZZs;   C7-C$	C&AC$	?C7C!C$	$C4/C77D	 N)rT   print_callersprint_callees)rG   r2   __qualname____firstlineno__profileProfiler%   rb   r*   rV   r   r   classmethodr@   rP   r[   rh   rn   rq   rx   r   __static_attributes____classdictcell__)__classdict__s   @r   r   r      sf     OOMNCK#  ('"M*0P
0
4: :r   r   c                    V P                  R 4      p \        RV ,          4       VP                  4       p. p\        V R4      ;_uu_ 4       pV F-  pVP	                  V4       VP                  R4      '       g   K-   M	  RRR4       \        V R4      ;_uu_ 4       pVP                  V4       VP                  R4       \        VP                  4       F,  w  rgVP                  RV: RW&^,           ,          : R	24       K.  	  VP                  R
4       RRR4       R#   + '       g   i     L; i  + '       g   i     R# ; i)cozRegenerating %s...rz#--cutNr|   z_ProfileOutput = {}
z_ProfileOutput[z	] = """\
z"""
z'
if __name__ == "__main__":
    main()
)
r4   printr@   r   r)   
startswith
writelinesr   rF   r*   )r`   r6   r7   newfilerm   r?   rL   rM   s   &&      r   regenerate_expected_outputr      s    t$H	

)* GG	h		DNN4 x((  
 
h			W	'("3??3IAGGGaCLL* + 4 	
<= 
	 
	 
		s   
+D:DA9D0D-	0E	c               #      "   \         P                  p  \        4       \         n        R x  V \         n        R #   T \         n        i ; i5ir   )sysstdoutr   )r   s    r   ra   ra      s-     ZZFZ

V
s   A8 AAAc                      R \         P                  9  d   \        P                  ! 4        R# \	        \
        \        4       R# )z-rN)r   argvunittestmainr   __file__r   r   r   r   r   r      s!    388"8[9r   a         28   27.972    0.999   27.972    0.999 profilee.py:110(__getattr__)
        1  269.996  269.996  999.769  999.769 profilee.py:25(testfunc)
     23/3  149.937    6.519  169.917   56.639 profilee.py:35(factorial)
       20   19.980    0.999   19.980    0.999 profilee.py:48(mul)
        2   39.986   19.993  599.830  299.915 profilee.py:55(helper)
        4  115.984   28.996  119.964   29.991 profilee.py:73(helper1)
        2   -0.006   -0.003  139.946   69.973 profilee.py:84(helper2_indirect)
        8  311.976   38.997  399.912   49.989 profilee.py:88(helper2)
        8   63.976    7.997   79.960    9.995 profilee.py:98(subhelper)rT   a  :0(append)                        <- profilee.py:73(helper1)(4)  119.964
:0(exception)                     <- profilee.py:73(helper1)(4)  119.964
:0(hasattr)                       <- profilee.py:73(helper1)(4)  119.964
                                     profilee.py:88(helper2)(8)  399.912
profilee.py:110(__getattr__)      <- :0(hasattr)(12)   11.964
                                     profilee.py:98(subhelper)(16)   79.960
profilee.py:25(testfunc)          <- <string>:1(<module>)(1)  999.767
profilee.py:35(factorial)         <- profilee.py:25(testfunc)(1)  999.769
                                     profilee.py:35(factorial)(20)  169.917
                                     profilee.py:84(helper2_indirect)(2)  139.946
profilee.py:48(mul)               <- profilee.py:35(factorial)(20)  169.917
profilee.py:55(helper)            <- profilee.py:25(testfunc)(2)  999.769
profilee.py:73(helper1)           <- profilee.py:55(helper)(4)  599.830
profilee.py:84(helper2_indirect)  <- profilee.py:55(helper)(2)  599.830
profilee.py:88(helper2)           <- profilee.py:55(helper)(6)  599.830
                                     profilee.py:84(helper2_indirect)(2)  139.946
profilee.py:98(subhelper)         <- profilee.py:88(helper2)(8)  399.912r   a  :0(hasattr)                       -> profilee.py:110(__getattr__)(12)   27.972
<string>:1(<module>)              -> profilee.py:25(testfunc)(1)  999.769
profilee.py:110(__getattr__)      ->
profilee.py:25(testfunc)          -> profilee.py:35(factorial)(1)  169.917
                                     profilee.py:55(helper)(2)  599.830
profilee.py:35(factorial)         -> profilee.py:35(factorial)(20)  169.917
                                     profilee.py:48(mul)(20)   19.980
profilee.py:48(mul)               ->
profilee.py:55(helper)            -> profilee.py:73(helper1)(4)  119.964
                                     profilee.py:84(helper2_indirect)(2)  139.946
                                     profilee.py:88(helper2)(6)  399.912
profilee.py:73(helper1)           -> :0(append)(4)   -0.004
profilee.py:84(helper2_indirect)  -> profilee.py:35(factorial)(2)  169.917
                                     profilee.py:88(helper2)(2)  399.912
profilee.py:88(helper2)           -> :0(hasattr)(8)   11.964
                                     profilee.py:98(subhelper)(8)   79.960
profilee.py:98(subhelper)         -> profilee.py:110(__getattr__)(16)   27.972r   __main__)r   r+   r   re   difflibr   ior   test.support.os_helperr   r   r   r   
contextlibr	   r
   r   test.profileer   r   test.support.script_helperr   r   TestCaser   r   ra   r   r   rG   r   r   r   <module>r      s       	    G G 6  ) Nr:(## r:j>(  : 	!K} #L $#R & zF r   