ó
ŒwÛjc           @   sÛ   d  d l  Z  d  d l Z d  d l Z d  d l m Z d  d l Z d  d l m Z d  d l m Z d  d l m	 Z	 d  d l m
 Z
 d Z d Z d	 f  d
 „  ƒ  YZ d e j f d „  ƒ  YZ d „  Z e d k r× e ƒ  n  d S(   iÿÿÿÿN(   t   StringIO(   t   dedent(   t   run_unittest(   t   captured_stdout(   t   captured_stderri@B i   t	   FakeTimerc           B   s>   e  Z d  Z d d „ Z d „  Z d „  Z d „  Z d „  Z RS(   g      E@g      ð?c         C   s(   d |  _  d |  _ | |  _ |  t _ d  S(   Ni    (   t   countt   setup_callst   seconds_per_incrementt   timeitt   _fake_timer(   t   selfR   (    (    s†   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/test_timeit.pyt   __init__   s    			c         C   s   |  j  |  j |  j S(   N(   t	   BASE_TIMER   R   (   R   (    (    s†   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/test_timeit.pyt   __call__    s    c         C   s   |  j  d 7_  d  S(   Ni   (   R   (   R   (    (    s†   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/test_timeit.pyt   inc#   s    c         C   s   |  j  d 7_  d  S(   Ni   (   R   (   R   (    (    s†   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/test_timeit.pyt   setup&   s    c         C   s   | |  _  |  S(   s3   Records 'timer' and returns self as callable timer.(   t   saved_timer(   R   t   timer(    (    s†   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/test_timeit.pyt
   wrap_timer)   s    	(   t   __name__t
   __module__R   R   R   R   R   R   (    (    (    s†   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/test_timeit.pyR      s   			t
   TestTimeitc           B   sÍ  e  Z d  „  Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z d Z	 d Z
 d	 „  Z d
 „  Z d1 d „ Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z d1 d1 d „ Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z d Z  d d1 d1 d „ Z! d  „  Z" d! „  Z# d" „  Z$ d# „  Z% d$ „  Z& d% „  Z' d& „  Z( d' „  Z) e* j+ e, j- j. d( k d) ƒ d* „  ƒ Z/ d+ „  Z0 d, „  Z1 d- „  Z2 d. „  Z3 d/ „  Z4 d0 „  Z5 RS(2   c         C   s"   y
 t  ` Wn t k
 r n Xd  S(   N(   R	   R
   t   AttributeError(   R   (    (    s†   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/test_timeit.pyt   tearDown0   s    
c         C   s<   |  j  t j d d ƒ d ƒ |  j  t j d d ƒ d ƒ d  S(   Nt    i    i   (   t   assertEqualR	   t   reindent(   R   (    (    s†   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/test_timeit.pyt   test_reindent_empty6   s    c         C   s<   |  j  t j d d ƒ d ƒ |  j  t j d d ƒ d ƒ d  S(   Nt   passi    i   (   R   R	   R   (   R   (    (    s†   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/test_timeit.pyt   test_reindent_single:   s    c         C   s<   |  j  t j d d ƒ d ƒ |  j  t j d d ƒ d ƒ d  S(   Ns   

i    i   s
   
    
    (   R   R	   R   (   R   (    (    s†   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/test_timeit.pyt   test_reindent_multi_empty>   s    c         C   s<   |  j  t j d d ƒ d ƒ |  j  t j d d ƒ d ƒ d  S(   Ns   print()
pass
breaki    i   s   print()
    pass
    break(   R   R	   R   (   R   (    (    s†   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/test_timeit.pyt   test_reindent_multiB   s    		c         C   s�   |  j  t t j d d  ƒ|  j  t t j d d ƒ|  j  t t j d d ƒ|  j  t t j d d ƒ|  j  t t j d d ƒd  S(   Nt   stmtt   returnt   yieldt   breakt   continue(   t   assertRaisest
   ValueErrorR	   t   Timert   Nonet   SyntaxError(   R   (    (    s†   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/test_timeit.pyt   test_timer_invalid_stmtJ   s
    c         C   s�   |  j  t t j d d  ƒ|  j  t t j d d ƒ|  j  t t j d d ƒ|  j  t t j d d ƒ|  j  t t j d d ƒd  S(   NR   R"   R#   R$   R%   (   R&   R'   R	   R(   R)   R*   (   R   (    (    s†   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/test_timeit.pyt   test_timer_invalid_setupQ   s
    s)   import timeit; timeit._fake_timer.setup()s'   import timeit; timeit._fake_timer.inc()c         C   s   |  j  j ƒ  d  S(   N(   t
   fake_timerR   (   R   (    (    s†   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/test_timeit.pyt   fake_callable_setup[   s    c         C   s   |  j  j ƒ  d  S(   N(   R-   R   (   R   (    (    s†   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/test_timeit.pyt   fake_callable_stmt^   s    c         C   s¡   t  ƒ  |  _ t j d | d | d |  j ƒ } i  } | d  k rH t } n
 | | d <| j | �  } |  j |  j j d ƒ |  j |  j j | ƒ |  j | | ƒ d  S(   NR!   R   R   t   numberi   (	   R   R-   R	   R(   R)   t   DEFAULT_NUMBERR   R   R   (   R   R!   R   R0   t   tt   kwargst
   delta_time(    (    s†   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/test_timeit.pyR	   a   s    !	
c         C   s    |  j  |  j |  j d d ƒd  S(   NR0   i    (   R	   t	   fake_stmtt
   fake_setup(   R   (    (    s†   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/test_timeit.pyt   test_timeit_zero_itersr   s    c         C   s    |  j  |  j |  j d d ƒd  S(   NR0   i   (   R	   R5   R6   (   R   (    (    s†   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/test_timeit.pyt   test_timeit_few_itersu   s    c         C   s    |  j  |  j |  j d d ƒd  S(   NR0   i   (   R	   R/   R6   (   R   (    (    s†   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/test_timeit.pyt   test_timeit_callable_stmtx   s    c         C   s    |  j  |  j |  j d d ƒd  S(   NR0   i   (   R	   R5   R.   (   R   (    (    s†   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/test_timeit.pyt   test_timeit_callable_setup{   s    c         C   s    |  j  |  j |  j d d ƒd  S(   NR0   i   (   R	   R/   R.   (   R   (    (    s†   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/test_timeit.pyt#   test_timeit_callable_stmt_and_setup~   s    c         C   s;   t  j  |  j |  j d d d t ƒ  ƒ} |  j | d ƒ d  S(   NR0   i    R   (   R	   R5   R6   R   R   (   R   R4   (    (    s†   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/test_timeit.pyt   test_timeit_function_zero_itersˆ   s    c         C   sÑ   t  ƒ  |  _ t j d | d | d |  j ƒ } i  } | d  k rH t } n
 | | d <| d  k rg t } n
 | | d <| j | �  } |  j |  j j	 | ƒ |  j |  j j
 | | ƒ |  j | | t | ƒ g ƒ d  S(   NR!   R   R   t   repeatR0   (   R   R-   R	   R(   R)   t   DEFAULT_REPEATR1   R=   R   R   R   t   float(   R   R!   R   R=   R0   R2   R3   t   delta_times(    (    s†   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/test_timeit.pyR=   �   s    !	
	
c         C   s    |  j  |  j |  j d d ƒd  S(   NR=   i    (   R=   R5   R6   (   R   (    (    s†   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/test_timeit.pyt   test_repeat_zero_reps¢   s    c         C   s    |  j  |  j |  j d d ƒd  S(   NR0   i    (   R=   R5   R6   (   R   (    (    s†   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/test_timeit.pyt   test_repeat_zero_iters¥   s    c         C   s&   |  j  |  j |  j d d d d ƒd  S(   NR=   i   R0   i   (   R=   R5   R6   (   R   (    (    s†   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/test_timeit.pyt   test_repeat_few_reps_and_iters¨   s    c         C   s&   |  j  |  j |  j d d d d ƒd  S(   NR=   i   R0   i   (   R=   R/   R6   (   R   (    (    s†   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/test_timeit.pyt   test_repeat_callable_stmt«   s    c         C   s&   |  j  |  j |  j d d d d ƒd  S(   NR=   i   R0   i   (   R=   R5   R.   (   R   (    (    s†   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/test_timeit.pyt   test_repeat_callable_setup¯   s    c         C   s&   |  j  |  j |  j d d d d ƒd  S(   NR=   i   R0   i   (   R=   R/   R.   (   R   (    (    s†   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/test_timeit.pyt#   test_repeat_callable_stmt_and_setup³   s    c         C   s;   t  j |  j |  j d d d t ƒ  ƒ} |  j | g  ƒ d  S(   NR=   i    R   (   R	   R=   R5   R6   R   R   (   R   R@   (    (    s†   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/test_timeit.pyt   test_repeat_function_zero_reps½   s    c         C   sB   t  j |  j |  j d d d t ƒ  ƒ} |  j | t d g ƒ d  S(   NR0   i    R   g        (   R	   R=   R5   R6   R   R   R>   (   R   R@   (    (    s†   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/test_timeit.pyt   test_repeat_function_zero_itersÂ   s    c         C   sZ   | j  ƒ  } |  j t | ƒ d ƒ |  j | d j d ƒ ƒ |  j | d j | ƒ ƒ d  S(   Ni   i    t	   Tracebackiÿÿÿÿ(   t
   splitlinest   assertGreatert   lent
   assertTruet
   startswith(   R   t
   exc_stringt   expected_exc_namet	   exc_lines(    (    s†   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/test_timeit.pyt   assert_exc_stringÇ   s    c         C   sW   t  ƒ  } t j d ƒ } y | j ƒ  Wn | j | ƒ n X|  j | j ƒ  d ƒ d  S(   Ns   1.0/0.0t   ZeroDivisionError(   R    R	   R(   t	   print_excRR   t   getvalue(   R   t   sR2   (    (    s†   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/test_timeit.pyt   test_print_excÍ   s    	s$   10 loops, best of 3: 1 sec per loop
g      ð?c      	   C   s”   | d  k r t d | ƒ } n  | d  k r3 g  } n | } | j |  j ƒ t j } t ƒ  �  } t j d | d | j	 ƒ Wd  QX| t j (| j
 ƒ  S(   NR   t   argst   _wrap_timer(   R)   R   t   appendR5   t   syst   pathR   R	   t   mainR   RU   (   R   R   t   switchesR   RX   t   orig_sys_pathRV   (    (    s†   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/test_timeit.pyt   run_mainØ   s    	
c         C   s/   |  j  d d g ƒ } |  j | t d ƒ ƒ d  S(   NR^   s   --bad-switchsk               option --bad-switch not recognized
            use -h/--help for command line help
            (   R`   R   R   (   R   RV   (    (    s†   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/test_timeit.pyt   test_main_bad_switchç   s    c         C   s&   |  j  d d ƒ } |  j | d ƒ d  S(   NR   g      @s&   10 loops, best of 3: 5.5 sec per loop
(   R`   R   (   R   RV   (    (    s†   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/test_timeit.pyt   test_main_secondsî   s    c         C   s&   |  j  d d ƒ } |  j | d ƒ d  S(   NR   gºI+‡v?s(   100 loops, best of 3: 5.5 msec per loop
(   R`   R   (   R   RV   (    (    s†   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/test_timeit.pyt   test_main_millisecondsò   s    c         C   s/   |  j  d d d d g ƒ } |  j | d ƒ d  S(   NR   gñhãˆµøÄ>R^   s   -n100s(   100 loops, best of 3: 2.5 usec per loop
(   R`   R   (   R   RV   (    (    s†   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/test_timeit.pyt   test_main_microsecondsö   s    c         C   s/   |  j  d d d d g ƒ } |  j | d ƒ d  S(   NR   g       @R^   s   -n35s$   35 loops, best of 3: 2 sec per loop
(   R`   R   (   R   RV   (    (    s†   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/test_timeit.pyt   test_main_fixed_itersú   s    c         C   s=   |  j  d d d d d d g ƒ } |  j | d d d	 ƒ d  S(
   NR   g       @R^   s   -n35s   -ss   print("CustomSetup")s   CustomSetup
i   s$   35 loops, best of 3: 2 sec per loop
(   R`   R   (   R   RV   (    (    s†   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/test_timeit.pyt   test_main_setupþ   s    c         C   s/   |  j  d d d d g ƒ } |  j | d ƒ d  S(   NR   g      N@R^   s   -r9s%   10 loops, best of 9: 60 sec per loop
(   R`   R   (   R   RV   (    (    s†   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/test_timeit.pyt   test_main_fixed_reps  s    c         C   s/   |  j  d d d d g ƒ } |  j | d ƒ d  S(   NR   g      N@R^   s   -r-5s%   10 loops, best of 1: 60 sec per loop
(   R`   R   (   R   RV   (    (    s†   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/test_timeit.pyt   test_main_negative_reps  s    i   s   need __doc__c         C   s,   |  j  d d g ƒ } |  j | t j ƒ d  S(   NR^   s   -h(   R`   R   R	   t   __doc__(   R   RV   (    (    s†   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/test_timeit.pyt   test_main_help  s    c         C   sQ   t  ƒ  } |  j d d g d | ƒ } |  j | |  j ƒ |  j | j t j ƒ d  S(   NR^   s   -tR   (   R   R`   R   t   MAIN_DEFAULT_OUTPUTt   assertIsR   t   time(   R   R-   RV   (    (    s†   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/test_timeit.pyt   test_main_using_time  s    	c         C   sQ   t  ƒ  } |  j d d g d | ƒ } |  j | |  j ƒ |  j | j t j ƒ d  S(   NR^   s   -cR   (   R   R`   R   Rk   Rl   R   Rm   t   clock(   R   R-   RV   (    (    s†   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/test_timeit.pyt   test_main_using_clock  s    	c         C   s/   |  j  d d g ƒ } |  j | t d ƒ ƒ d  S(   NR^   s   -vsˆ                   10 loops -> 10 secs
                raw times: 10 10 10
                10 loops, best of 3: 1 sec per loop
            (   R`   R   R   (   R   RV   (    (    s†   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/test_timeit.pyt   test_main_verbose  s    c         C   s5   |  j  d d d d g ƒ } |  j | t d ƒ ƒ d  S(   NR   g-Cëâ6
?R^   s   -vvs                  10 loops -> 0.0005 secs
                100 loops -> 0.005 secs
                1000 loops -> 0.05 secs
                10000 loops -> 0.5 secs
                raw times: 0.5 0.5 0.5
                10000 loops, best of 3: 50 usec per loop
            (   R`   R   R   (   R   RV   (    (    s†   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/test_timeit.pyt   test_main_very_verbose%  s    c         C   sA   t  ƒ  � } |  j d d g ƒ } Wd  QX|  j | j ƒ  d ƒ d  S(   NR^   s   1.0/0.0RS   (   R   R`   RR   RU   (   R   t   error_stringioRV   (    (    s†   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/test_timeit.pyt   test_main_exception0  s    c         C   sD   t  ƒ  � } |  j d d d g ƒ } Wd  QX|  j | j ƒ  d ƒ d  S(   NR^   s   -n1s   1.0/0.0RS   (   R   R`   RR   RU   (   R   Rs   RV   (    (    s†   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/test_timeit.pyt   test_main_exception_fixed_reps5  s    N(6   R   R   R   R   R   R   R    R+   R,   R6   R5   R.   R/   R)   R	   R7   R8   R9   R:   R;   R<   R=   RA   RB   RC   RD   RE   RF   RG   RH   RR   RW   Rk   R`   Ra   Rb   Rc   Rd   Re   Rf   Rg   Rh   t   unittestt   skipIfR[   t   flagst   optimizeRj   Rn   Rp   Rq   Rr   Rt   Ru   (    (    (    s†   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/test_timeit.pyR   .   s\   														
							
													'					c           C   s   t  t ƒ d  S(   N(   R   R   (    (    (    s†   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/test_timeit.pyt	   test_main;  s    t   __main__(   R	   Rv   R[   R    Rm   t   textwrapR   t   test.test_supportR   R   R   R1   R>   R   t   TestCaseR   Rz   R   (    (    (    s†   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/test_timeit.pyt   <module>   s    ÿ 	