1 Medley for the Novice, Release 2.0 1 Medley for the Novice, Release 2.0 19. WHERE DOES ALL THE TIME GO? SPY 1 19. WHERE DOES ALL THE TIME GO? SPY 1 "19"19. WHERE DOES ALL THE TIME GO? SPY 6 SPY(SPY NIL NIL NIL NIL 1) is an Lisp library package that shows you where you spend your time when you run your system. It is easy to learn, and very useful when trying to make programs run faster. How to Use Spy with the SPY Window 1 The function SPY.BUTTON(SPY.BUTTON (Function) NIL NIL NIL 1) brings up a small window which you will be prompted to position. Using the mouse buttons in this window controls the action of the SPY program. When you are not using SPY, the window appears as in Figure 19.1. CF```c!f66 f630 g30 c13 `3 f63 f63 Qf63 c `!`` `JQdP@ `_T!dA?z`*~K@I`AVڄ b`_T(QeRcoґcy c$ e icAeROig"/`]~ـeRd/b_}B Iaid+Qbb;e b4Qd&!ft%B Qa IP dZ$d)bJTZPI` ""!a za@@!daX""#P a!bAHX ad"!eETA ay!``;w@ `MQ`#} ` !dAV`` Figure 19.1. SPY Window(SPY% WINDOW NIL SPY% Window NIL NIL 1) When SPY is Not Being Used To use SPY, click either the left or middle mouse button with the mouse cursor in the SPY window. The window will appear as in Figure 19.2, and means that SPY is accumulating data about your program. BF0ll0lf` f`c l` l`l l`l l`l l``ȠnCȂ #TҗꀓU? SQSߥ#@ Hs@Ђ%ksʤ(AD_sUʥ. _sľA&+o@VYU lRe#/@SUOZR RCDԉR+SČ}]/C´_#¹/_C/AMtW &,CP_@CA BV C @ @@CȀ # Figure 19.2. SPY Window When SPY is Being Used To turn off SPY after the program has run, again click a mouse button in the SPY window. The eye closes, and you are asked to position another window. This window contains SPY's results. An example of the resulting window is shown in Figure 19.3. h~?}wݻ}wݻtw?~ݻݙ񻷶?ͻ}ݻݻ~⻴w?```DDDDD`f e Ac3330 >1 BRc3330 M@(JX BPf, O@BBPeJ%1 BPc0,J€%X BRc0,HH(JXyf,MH1eLc0c0 f,ec0c0f, e c0 c0 f, e@ c0@ c0 8FIdsgf,R$RR JR%,e B$b JR! c0 8bܔ sc0%RT B,f,.%JR$BR%,eOEc%BLgc0 c0 f, e  c0@ c0@ f,@ e c0 c0f, ec0 c0@ f, e c0" ?c0$ f,H e DDFc @c2R1 @6f- "31\d@I.CNeZR7)J(JX$RAJPBH@FcR1 P?)BB ҔJBH@^cR1+)3%18 ҔAYIC@Nf, +) %X$ ґAYHPiB@Ne#)J(JX$҇JPDiB\>c0@3Ȅ1:\b1D.{@c0 f, e DDFc0 DDFc0 f, e c0 c0 f, ec0c0@UUUUUUUUUUUf, e UUUUUUUUUUUc0 c0PUVf, ePUVc0333330 c0333330330333P@f,. 3?e Y07)J"Hc00303333?)B" &c0@00R+)3"H&f,@,+) ' Fe X#)J$IHc0 08"3$Ic000`P]f,, e P@c000 c0000PUVf,, e PUVc000 c000UUUUUUUUUUUf,NgK,`eMJIUUUUUUUUUUUc0#z2R kc0#!300P {UVf,zze JRBYUVc0bJL02RB[c001GK@f,`e @c333000c333000@`,`` @`00`00C36`,` @*JR`  BRB`00@ W [`00@$ J%H`,Ȁ$)@` ܀' :Ld^f`00`333330333333@`.` @`333330333333`@``@``@``UV``UV`` Figure 19.3. Window Produced After Running SPY This window is scrollable horizontally and vertically. This is useful, since the whole tree does not fit in the window. If a part that you want to see is not shown, you can scroll the window to show the part you want to see. How to Use SPY from the Lisp Top Level 1 SPY(SPY NIL NIL NIL NIL 2 SUBNAME HOW% TO% USE SUBTEXT how% to% use) can also be run while a specific function or system is being used. To do this, type the function WITH.SPY(WITH.SPY (Function) NIL NIL NIL 2): (WITH.SPY form) The expression used for form should be the call to begin running the function or system that SPY is to watch. If you watch the SPY window, the eye will blink! To see your results, run the function SPY.TREE(SPY.TREE (Function) NIL NIL NIL 2). To do this, type: (SPY.TREE) The results of the last running of SPY will be displayed. If you do this, and SPY.TREE returns (no SPY samples have been gathered), your function ran too fast for SPY to follow. Interpreting SPY's Results 1 Each node in the tree is a box that contains, first, the percentage of time spent running that particular function, and second, the function name. There are two modes that can be used to display this tree.(SPY NIL NIL NIL NIL 2 SUBNAME INTERPRETING% RESULTS SUBTEXT interpreting% results) The default mode is cumulative. In this mode, each percentage is the amount of time that function spent on top of the stack, plus the amount of time spent by the functions it calls. The second mode is individual. To change the mode to individual, point to the title bar of the window, and press the middle mouse button. Choose Individual from the menu that appears. In this mode, the percentage shown is the amount of time the function spent on the top of the stack. To look at a single branch of the tree, point with the mouse cursor at one of the nodes of the tree, and press the right mouse button. From the menu that appears, choose the option SubTree. Another SPY window will appear, with just this branch of the tree in it. Another way to focus within the tree is to remove branches from the tree. To do this, point to the node at the top of the branch you would like to delete. Press the middle mouse button, and choose Delete from the menu that appears. There are also different amounts of "merging" of functions that can be done in the window. A function can be called by another function more than once. The amount of merging determines where the subfunction, and the functions that it calls, appear in the tree, and how often. (For a detailed explanation of merging, see the Lisp Library Packages Manual.) (LIST ((PAGE NIL (PAPERSIZE Letter FOLIOINFO (ARABIC "19-" "") STARTINGPAGE# 1) (0 0 612 792) ((FOLIO NIL (PARALOOKS (QUAD RIGHT) CHARLOOKS (SUPERSCRIPT 0 INVISIBLE OFF SELECTPOINT OFF PROTECTED OFF SIZE 10 FAMILY HELVETICA OVERLINE OFF STRIKEOUT OFF UNDERLINE OFF EXPANSION REGULAR SLOPE REGULAR WEIGHT MEDIUM INVERTED OFF USERINFO NIL STYLE NIL) FORMATINFO (ARABIC "19-" "")) (270 15 288 36) NIL) (HEADING NIL (HEADINGTYPE FOOTINGR) (54 27 558 36) NIL) (TEXT NIL NIL (54 54 504 690) NIL))) (PAGE NIL (PAPERSIZE Letter FOLIOINFO (ARABIC "19-" "")) (0 0 612 792) ((FOLIO NIL (PARALOOKS (QUAD LEFT) CHARLOOKS (SUPERSCRIPT 0 INVISIBLE OFF SELECTPOINT OFF PROTECTED OFF SIZE 10 FAMILY HELVETICA OVERLINE OFF STRIKEOUT OFF UNDERLINE OFF EXPANSION REGULAR SLOPE REGULAR WEIGHT MEDIUM INVERTED OFF USERINFO NIL STYLE NIL) FORMATINFO (ARABIC "19-" "")) (54 15 288 36) NIL) (HEADING NIL (HEADINGTYPE FOOTINGV) (54 27 558 36) NIL) (HEADING NIL (HEADINGTYPE VERSOHEAD) (54 762 558 36) NIL) (TEXT NIL NIL (54 54 504 684) NIL))) (PAGE NIL (PAPERSIZE Letter FOLIOINFO (ARABIC "19-" "")) (0 0 612 792) ((FOLIO NIL (PARALOOKS (QUAD RIGHT) CHARLOOKS (SUPERSCRIPT 0 INVISIBLE OFF SELECTPOINT OFF PROTECTED OFF SIZE 10 FAMILY HELVETICA OVERLINE OFF STRIKEOUT OFF UNDERLINE OFF EXPANSION REGULAR SLOPE REGULAR WEIGHT MEDIUM INVERTED OFF USERINFO NIL STYLE NIL) FORMATINFO (ARABIC "19-" "")) (270 15 288 36) NIL) (HEADING NIL (HEADINGTYPE FOOTINGR) (54 27 558 36) NIL) (HEADING NIL (HEADINGTYPE RECTOHEAD) (54 762 558 36) NIL) (TEXT NIL NIL (54 54 504 684) NIL)))))-HH T,HH ,,ll,HH,HH,HH -T-T,HH,25F PAGEHEADING VERSOHEADF PAGEHEADING RECTOHEADE PAGEHEADINGFOOTINGVE PAGEHEADINGFOOTINGR, CLASSIC TITAN CLASSIC HELVETICAMODERN HELVETICACLASSIC  HELVETICA MODERN  TIMESROMAN  TIMESROMAN  HRULE.GETFNMODERN  " HRULE.GETFNCLASSIC #& HRULE.GETFNCLASSIC % HRULE.GETFNCLASSIC   IM.CHAP.GETFN HELVETICA&  HRULE.GETFNMODERN    IM.INDEX.GETFN  # HRULE.GETFNCLASSIC    %IM.INDEX.GETFN!( BMOBJ.GETFN3 'IM.INDEX.GETFNLB* BMOBJ.GETFN3CLASSIC     >\H BMOBJ.GETFN3CLASSIC + ' HRULE.GETFNCLASSIC  AIM.INDEX.GETFNb#IM.INDEX.GETFN C#IM.INDEX.GETFN #( =    HRULE.GETFNCLASSICSIM.INDEX.GETFNTITAN G  >D1z