ó ükWc@sĄdZddlZddlZddlZddlZddlZddlZejƒZd„Z d„Z d„Z d„Z d„Z edkre ƒ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/lib/python2.7/test/sortperf.pyt randfloatss<  "       cCstjjƒdS(N(tsyststdouttflush(((s#/usr/lib/python2.7/test/sortperf.pyR#8scCs9tjƒ}|jƒtjƒ}d||GtƒdS(Ns%6.2f(ttimetclocktsortR#(tLtt0tt1((s#/usr/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/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/lib/python2.7/test/sortperf.pytmainŽs    t__main__(t__doc__R!R$R R ttempfileRt gettempdirRR R#R*R8R@t__name__(((s#/usr/lib/python2.7/test/sortperf.pyts        '   L