%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /usr/local/lib/python2.7/test/
Upload File :
Create Path :
Current File : //usr/local/lib/python2.7/test/sortperf.pyc

ó
Nęáac@sĄdZddlZddlZddlZddlZddlZddlZejƒZd„Z	d„Z
d„Zd„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%06dtrbtwbNscan'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

cCs;tgdD]}|d^q
ƒ}ddt|ƒ}|d|GHxđ|D]č}d|>}t|ƒ}d||fGtƒt|ƒ|jƒt|ƒt|ƒxOtd	ƒD]A}tj|ƒ}tj|ƒ}	||	||||<||	<qąWt|ƒ|d
kr8gtd
ƒD]}tjƒ^q|d)nt|ƒx1t	|dƒD]}tjƒ|tj|ƒ<qSWt|ƒ|d
krś|d
3||d
}t
d„|ƒ}nt|ƒ~t
tdg|ƒ}t|ƒ~|d}
t|
dddƒ}|jt|
ƒƒt
t
|ƒ}t|ƒHqKWdS(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 %6sRs2**iis%2d %7dii
iö˙˙˙idicSs|S(N((tx((s)/usr/local/lib/python2.7/test/sortperf.pyt<lambda>ytgŕż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	tseedRR9(tk1tk2R+taR((s)/usr/local/lib/python2.7/test/sortperf.pytmainŽs	


t__main__(t__doc__R!R$R	RttempfileRt
gettempdirRR R#R*R9RAt__name__(((s)/usr/local/lib/python2.7/test/sortperf.pyt<module>s	'			L	

Zerion Mini Shell 1.0