tzh
2024-08-22 c7d0944258c7d0943aa7b2211498fd612971ce27
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
N\¬Qc@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((sU/tmp/ndk-User/buildhost/install/prebuilt/darwin-x86_64/lib/python2.7/test/sortperf.pyt
randfloatss<     "
 
 
 
 
 cCstjjƒdS(N(tsyststdouttflush(((sU/tmp/ndk-User/buildhost/install/prebuilt/darwin-x86_64/lib/python2.7/test/sortperf.pyR#8scCs9tjƒ}|jƒtjƒ}d||GtƒdS(Ns%6.2f(ttimetclocktsortR#(tLtt0tt1((sU/tmp/ndk-User/buildhost/install/prebuilt/darwin-x86_64/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|ƒ}    ||    ||||<||    <q±Wt|ƒ|d
kr8gtd
ƒD]}tjƒ^q|d )nt|ƒx1t    |d ƒD]}tjƒ|tj|ƒ<qSWt|ƒ|d kr¶|d 3||d }t
d„|ƒ}nt|ƒ~t
t dg|ƒ}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((sU/tmp/ndk-User/buildhost/install/prebuilt/darwin-x86_64/lib/python2.7/test/sortperf.pyt<lambda>ysgà¿iiÿÿÿÿN(Rs2**i(ttupleRR R#R*RRR    RR
tmaptabsRtfloat( RtchtcasestfmtRRR'tdummyti1ti2thalf((sU/tmp/ndk-User/buildhost/install/prebuilt/darwin-x86_64/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((sU/tmp/ndk-User/buildhost/install/prebuilt/darwin-x86_64/lib/python2.7/test/sortperf.pytmainŽs       t__main__(t__doc__R!R$R    R ttempfileRt
gettempdirRR R#R*R8R@t__name__(((sU/tmp/ndk-User/buildhost/install/prebuilt/darwin-x86_64/lib/python2.7/test/sortperf.pyt<module>s           '            L