Tryag File Manager
Home
-
Turbo Force
Current Path :
/
usr
/
lib
/
python2.4
/
test
/
Upload File :
New :
File
Dir
//usr/lib/python2.4/test/sortperf.pyc
mò ‚=5Dc @ s‘ d Z d k Z d k Z d k Z d k Z d k Z d k Z e i ƒ Z d „ Z d „ Z d „ Z d „ Z d „ Z e d j o e ƒ n d S( s_ Sort performance test. See main() for command line syntax. See tabulate() for output format. Nc C s– t i i t d | ƒ } y t | d ƒ } Wnß t j oÓ t i } g } t | ƒ D] } | | ƒ qW ~ } yp z3 t | d ƒ } t i | | ƒ | i ƒ d } Wd | o. y t i | ƒ WqÞ t i j o qÞ Xn XWqxt j o } d G| Gd G| GHqxXnl Xt i | ƒ } | i ƒ xN t d ƒ D]@ } t i | ƒ } | | } | | 4| i ƒ | i | ƒ ~ q4Wt | ƒ | j p t ‚ | 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 nt fnt opent fpt IOErrort randomt rt _[1]t xranget it resultt marshalt dumpt closet Nonet unlinkt errort msgt loadt ranget randranget tempt reverset extendt lent AssertionError( R R R R R R R R R ( ( t# /usr/lib/python2.4/test/sortperf.pyt randfloats sB * c C s t i i ƒ d S( N( t syst stdoutt flush( ( ( R! R% 8 s c C s9 t i ƒ } | i ƒ t i ƒ } d | | Gt ƒ d S( Ns %6.2f( t timet clockt t0t Lt sortt t1R% ( R) R+ R( ( ( R! t doit; s c C sP t g } d D] } | | d q ~ ƒ } d d t | ƒ } | d | GHxý| D]õ} d | >} t | ƒ } d | | f Gt ƒ t | ƒ | i ƒ t | ƒ t | ƒ xO t d ƒ D]A } t i | ƒ } t i | ƒ } | | | | | | <| | <q¹ Wt | ƒ | d j o5 g } t d ƒ D] } | t i ƒ q&~ | d )n t | ƒ x1 t | d ƒ D] } t i ƒ | t i | ƒ <qeWt | ƒ | d j o+ | d 3| | d } t d „ | ƒ } n t | ƒ ~ t t d g | ƒ } t | ƒ ~ | d } t | d d d ƒ } | i t | ƒ ƒ t t | ƒ } t | ƒ HqS 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 C s | S( N( t x( R- ( ( R! t <lambda>y s f0.5i iÿÿÿÿN( R s 2**i( t tupleR t cht casesR t fmtR R R R"