Comment detail

実行時間の測定 (Nested Flatten)
#6128 をベースに少しいじりました。
実際に使用するならば #6128 のほうが融通が効く気がします。


 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
%!PS
/TimerStart { % (Label) TimerStart -  
    (Enter: ) print dup =
    currentdict /ProfilingTimer known not {
        /ProfilingTimer  10 dict def
    } if
    ProfilingTimer exch 2 copy known {
        get
    } {
        [0 0] dup 4 1 roll put
    } ifelse
    1 usertime 1000 div put 
} bind def

/TimerStop { % (Label) TimerStop -  
    (Leave: ) print dup print ( : ) print
    
    currentdict /ProfilingTimer known {
        ProfilingTimer exch 2 copy known
        {
            get
            aload 3 1 roll
            usertime 1000 div sub neg
            dup 10 string cvs print ( sec  Total =) print
            add
            dup 10 string cvs print ( sec) =
            0 exch put
        } {
            pop pop
        } ifelse
    } {
        pop
    } ifelse
} bind def

/profile { % ...function arguments...  /Function  profile  -
    currentdict /ProfileFunction-temp known not {
        /ProfileFunction-temp [] def
    } if
    dup 
    ProfileFunction-temp aload length 1 add dup 1 add -1 roll exch
    % /Func [F1 (Func)]
    array astore /ProfileFunction-temp exch def
    dup 100 string cvs TimerStart 
    cvx exec
    ProfileFunction-temp aload length 1 sub exch
    100 string cvs TimerStop
    array astore /ProfileFunction-temp exch def
} bind def
% ----------------- Test Code ----------------

/TestLoop2 { % Count  TestLoop2 -
    10000 mul {
        1000 {
        } repeat
    } repeat
} def 

/TestLoop { % - TestLoop -
    0 1 5 {
        /TestLoop2 profile
    } for
} def

/TestLoop profile

Index

Feed

Other

Link

Pathtraq

loading...