shell bypass 403
�
?��cc @ s� d Z d d l Z d d l Z d d l Z d d l Z d d l Z d d l Z e j � Z d � Z d � Z
d � Z d � Z d � Z
e d k r� e
� n d S( s_ Sort performance test.
See main() for command line syntax.
See tabulate() for output format.
i����Nc C sl t j j t d | � } y t | d � } Wn� t k
r� t j } g t | � D] } | � ^ qR } yl z3 t | d � } t j | | � | j
� d } Wd | r� y t j | � Wq� t j
k
r� q� Xn XWqht k
r� } d G| Gd G| GHqhXnk Xt j | � } | j
� xN t d � D]@ } t j | � } | | } | | 4| j � | j | � ~ q$W| S( s+ Return a list of n random floats in [0, 1).s rr%06dt rbt wbNs can't writet :i
( t ost patht joint tdt opent IOErrort randomt xranget marshalt dumpt closet Nonet unlinkt errort loadt ranget randranget reverset extend( t nt fnt fpt rt it resultt msgt temp( ( s4 /usr/local/python-2.7/lib/python2.7/test/sortperf.pyt
randfloats s:
"
c C s t j j � d S( N( t syst stdoutt flush( ( ( s4 /usr/local/python-2.7/lib/python2.7/test/sortperf.pyR! 8 s c C s9 t j � } | j � t j � } d | | Gt � d S( Ns %6.2f( t timet clockt sortR! ( t Lt t0t t1( ( s4 /usr/local/python-2.7/lib/python2.7/test/sortperf.pyt doit; s
c C s; t g d D] } | d ^ q
� } d d t | � } | d | GHx�| D]�} d | >} t | � } d | | f Gt � t | � | j � t | � t | � xO t d � D]A } t j | � } t j | � } | | | | | | <| | <q� Wt | � | d
k r8g t d
� D] } t j � ^ q| d )n t | � x1 t | d � D] } t j � | t j | � <qSWt | � | d
k r�| d
3| | d
} t
d � | � } n t | � ~ t
t d g | � } t | � ~ | d }
t |
d d d � } | j t |
� � t
t
| � } t | � HqK Wd S( s: Tabulate sort speed for lists of various sizes.
The sizes are 2**i for i in r (the argument, a list).
The output displays i, 2**i, and the time to sort arrays of 2**i
floating point numbers with the following properties:
*sort: random data
\sort: descending data
/sort: ascending data
3sort: ascending, then 3 random exchanges
+sort: ascending, then 10 random at the end
%sort: ascending, then randomly replace 1% of the elements w/ random values
~sort: many duplicates
=sort: all equal
!sort: worst case scenario
s *\/3+%~=!R$ s %2s %7ss %6sR s 2**ii s %2d %7di i
i����id i c S s | S( N( ( t x( ( s4 /usr/local/python-2.7/lib/python2.7/test/sortperf.pyt <lambda>y t g �i i����N( R s 2**i( t tuplet lenR R! R( R R R R R
t mapt absR t float( R t cht casest fmtR R R% t dummyt i1t i2t half( ( s4 /usr/local/python-2.7/lib/python2.7/test/sortperf.pyt tabulateB sL #
!
,
c C s� d } d } t j d r� t t j d � } } t j d r� t t j d � } t j d r� d } x) t j d D] } d | t | � } qq Wt j | � q� q� n t | | d � } t | � d S( s� Main program when invoked as a script.
One argument: tabulate a single row.
Two arguments: tabulate a range (inclusive).
Extra arguments are used to seed the random generator.
i i i i i i�
N( R t argvt intt hashR t seedR R8 ( t k1t k2R) t aR ( ( s4 /usr/local/python-2.7/lib/python2.7/test/sortperf.pyt main� s
t __main__( t __doc__R R"