mò %U²Ic@s‘dZdkZdkZdkZdkZdkZdkZeiƒZd„Z d„Z d„Z d„Z d„Z edjo e ƒndS(s_Sort performance test. See main() for command line syntax. See tabulate() for output format. Nc Cs–tiitd|ƒ}yt|dƒ}Wnßtj oÓt i }g}t |ƒD]}||ƒqW~}ypz3t|dƒ}ti||ƒ|iƒd}Wd|o.yti|ƒWqÞtij oqÞXnXWqxtj o}dG|GdG|GHqxXnlXti|ƒ}|iƒxNtdƒD]@}t i|ƒ}|| }||4|iƒ|i|ƒ~q4Wt|ƒ|jpt‚|S(s+Return a list of n random floats in [0, 1).srr%06dtrbtwbNs can't writet:i (tostpathtjointtdtntfntopentfptIOErrortrandomtrt_[1]txrangetitresulttmarshaltdumptclosetNonetunlinkterrortmsgtloadtranget randrangettemptreversetextendtlentAssertionError( RR RRRR RRR((t*/data/zmath/lib/python2.4/test/sortperf.pyt randfloatssB *       cCstiiƒdS(N(tsyststdouttflush(((R!R%8scCs9tiƒ}|iƒtiƒ}d||GtƒdS(Ns%6.2f(ttimetclocktt0tLtsorttt1R%(R)R+R(((R!tdoit;s     c CsPtg} dD]}| |dq~ ƒ}ddt|ƒ}|d|GHxý|D]õ} d| >} t | ƒ}d| | fGt ƒt |ƒ|i ƒt |ƒt |ƒxOtd ƒD]A}ti| ƒ}ti| ƒ}||||||<||ysf0.5iiÿÿÿÿN(Rs2**i(ttupleRtchtcasesRtfmtR RRR"R)R%R,RRtdummyR Rti1ti2RtmaptabsthalfRtfloat( R R0R2R4R5R)R8R1R3RRR((R!ttabulateBsT+        !  5       cCsÌd}d}tido‘ttidƒ}}tidohttidƒ}tidoCd}x)tidD]}d|t|ƒ}qtWti |ƒq§q«nt ||dƒ}t |ƒdS(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. iiiiiiÍ N( tk1tk2R#targvtintR-tathashR tseedRR R:(R?R<R;R R-((R!tmainŽst__main__(t__doc__R#R&R RttempfileRt gettempdirRR"R%R,R:RBt__name__( R,R"RER R%R#R&RRBRRR:((R!t?s        '   L