ó {G_Tc@s¡dZddlZddlZddlZddlZddlZddlZejƒZd„Z d„Z d„Z d„Z d„Z edkre ƒndS( s_Sort performance test. See main() for command line syntax. See tabulate() for output format. iÿÿÿÿNcCs„tjjtd|ƒ}yt|dƒ}WnÏtk rýtj}gt|ƒD]}|ƒ^qR}ylz3t|dƒ}tj ||ƒ|j ƒd}Wd|rÑytj |ƒWqÑtj k rÍqÑXnXWqhtk rù}dG|GdG|GHqhXnkXtj|ƒ}|j ƒxNtdƒD]@}tj|ƒ}|| }||4|jƒ|j|ƒ~q$Wt|ƒ|ks€t‚|S(s+Return a list of n random floats in [0, 1).srr%06dtrbtwbNs can't writet:i (tostpathtjointtdtopentIOErrortrandomtxrangetmarshaltdumptclosetNonetunlinkterrortloadtranget randrangetreversetextendtlentAssertionError(tntfntfptrtitresulttmsgttemp((s)/usr/local/lib/python2.7/test/sortperf.pyt randfloatss<  "       cCstjjƒdS(N(tsyststdouttflush(((s)/usr/local/lib/python2.7/test/sortperf.pyR#8scCs9tjƒ}|jƒtjƒ}d||GtƒdS(Ns%6.2f(ttimetclocktsortR#(tLtt0tt1((s)/usr/local/lib/python2.7/test/sortperf.pytdoit;s     c Cs;tgdD]}|d^q ƒ}ddt|ƒ}|d|GHxð|D]è}d|>}t|ƒ}d||fGtƒt|ƒ|jƒt|ƒt|ƒxOtd ƒD]A}tj|ƒ}tj|ƒ} || ||||<|| ysgà¿iiÿÿÿÿN(Rs2**i(ttupleRR R#R*RRR RR tmaptabsRtfloat( RtchtcasestfmtRRR'tdummyti1ti2thalf((s)/usr/local/lib/python2.7/test/sortperf.pyttabulateBsL#        !  ,       cCsÆd}d}tjdr¥ttjdƒ}}tjdr¥ttjdƒ}tjdr¢d}x)tjdD]}d|t|ƒ}qqWtj|ƒ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(R!targvtintthashR tseedRR8(tk1tk2R+taR((s)/usr/local/lib/python2.7/test/sortperf.pytmainŽs    t__main__(t__doc__R!R$R R ttempfileRt gettempdirRR R#R*R8R@t__name__(((s)/usr/local/lib/python2.7/test/sortperf.pyts        '   L