I ~ User's Guide e=r e-a. -· ... Ci" I User's Guide Borland® Turbo Profiler® Borland International, Inc., 100 Borland Way P.O. Box 660001, Scotts Valley, CA 95067-0001 Borland may have patents and/or pending patent applications covering subject matter in this document. The furnishing of this document does not give you any license to these patents. COPYRIGHT© 1988, 1994 Borland International. All rights reserved. All Borland products are trademarks or registered trademarks of Borland International, Inc. Other brand and product names are trademarks or registered trademarks of their respective holders. Printed in the U.S.A. 1EOR1094 9495969798-9 8 7 6 5 4 3 2 Hl Contents Introduction 1 Restore Standard . . . . . . . . . . . . . . . . . 23 About ........................ 24 The difference between optimizing and File menu . . . . . . . . . . . . . . . . . . . . . . 24 profiling . . . . . . . . . . . . . . . . . . . . . . .2 Open ........................ 24 Hardware and software requirements . . . . . .2 Session Saving . . . . . . . . . . . . . . . . . 25 New features for version 4.5 .. 2 Get Info ....................... 26 What's in this manual ................ 3 DOS Shell . . . . . . . . . . . . . . . . . . . . . 27 Typeface con-..v,.entiorls . . . . . . . . . . . . . . . . 3 Quit ......................... 27 Software Registration and Technical Support .. 4 View menu . . . . . . . . . . . . . . . . . . . . . 27 SpeedMenus. . . . . . . . . . . . . . . . . . . . 28 Chapter 1 Module ....................... 28 A sampl!! profiling session 5 Line ....................... 29 Search ...................... 29 About the sample programs . . . . . . . . . . . .6 Next ....................... 29 Profiling a program (PRlMEO) . . . . . . . . . . . 6 Goto ....................... 30 Setting up the profile options . . . . . . . . . . . .7 Add Areas . . . . . . . . . . . . . . . . . . . 30 Collecting data ....................8 Remove Areas . . . . . . . . . . . . . . . . . 30 Displaying statistics . . . . . . . . . . . . . . . . .8 Operation .................... 30 Callers ....................... 32 Printing modules and statistics. . . . . . . . . . 10 Module ..................... 32 Time and counts profile listing . . . . . . . . . . 10 File ........................ 33 Profile statistics report . . . . . . . . . . . . . . . 11 Edit command . . . . . . . . . . . . . . . . . 33 Saving and restoring statistics . . . . . . . . . . 12 Execution Profile . . . . . . . . . . . . . . . . . 33 Analyzing the statistics . . . . . . . . . . . . . . 12 Display ..................... 34 Viewing both source code and statistics . . . . 12 Filter ....................... 35 Saving the window configuration. . . . . . . 13 Module ..................... 36 Measuring an area's efficiency . . . . . . . . . . 14 Position ..................... 36 Remove ..................... 36 A modularized primes test (PRlMEl) ...... 15 Callers ....................... 37 Modifying the program and reprofiling . . . . 16 Inspect (left pane) ............... 39 Loading another program (PRIME2) ...... 16 Inspect (right pane) .............. 39 Reducing calls to a routine (PRIME3) ...... 16 Sort (right pane) ................ 39 Still more efficiency (PRIME4) . . . . . . . . . . 17 Overlays . . . . . . . . . . . . . . . . . . . . . . 39 Eliminating CR/LF pairs (PRIMES) . . . . . . . 17 Display ..................... 40 Where to now? . . . . . . . . . . . . . . . . . . . 18 Inspect ..................... 40 Interrupts . . . . . . . . . . . . . . . . . . . . . 40 Chapter 2 Collection (top pane) ............. 41 The Turbo Profiler environment 19 Subfunctions (top pane) ........... 41 Add (top pane) ................ 41 Part 1: The environment components . . . 19 Pick (top pane) ................. 41 The menu bar and menus ............. 19 Remove (top pane) .............. 42 Choosing menu commands from the Delete All (top pane) ............. 42 keyboard. . . . . . . . . . . . . . . . . . . . . 20 Display (bottom pane) ............ 42 SpeedMenus . . . . . . . . . . . . . . . . . . 20 Files ......................... 42 Choosing menu commands with the mouse. 20 Collection (top pane) ............. 43 Shortcuts . . . . . . . . . . . . . . . . . . . . . . . 20 Detail (top pane) ................ 43 Turbo Profiler windows . . . . . . . . . . . . . . 21 When Full (top pane) ............. 43 Window management. . . . . . . . . . . . . . 21 Display (bottom pane) ............ 43 The status line . . . . . . . . . . . . . . . . . . . . 22 Areas ........................ 44 Dialog boxes. . . . . . . . . . . . . . . . . . . . . 23 Add Areas . . . . . . . . . . . . . . . . . . . 45 Part 2: The menu reference . . . . . . . . . . . . 23 Remove Areas . . . . . . . . . . . . . . . . . 45 = menu (System) . . . . . . . . . . . . . . . . . . 23 Inspect ..................... 45 Repaint Desktop . . . . . . . . . . . . . . . . . 23 Options ..................... 45 Sort ........................ 46 Recording macros . . . . . . . . . . . . . . . 63 Routines . . . . . . . . . . . . . . . . . . . . . . 46 Display Options . . . . . . . . . . . . . . . . . 64 Local Module (right pane) .......... 47 Display Swapping. . . . . . . . . . . . . . . 64 Areas (both panes). . . . . . . . . . . . . . . 47 Screen Lines . . . . . . . . . . . . . . . . . . 64 Callers (both panes) .............. 47 Tab Size ..................... 65 Module (both panes) ............. 47 Width of Names. . . . . . . . . . . . . . . . 65 Profile (both panes) . . . . . . . . . . . . . . 47 Path for Source . . . . . . . . . . . . . . . . . . 65 Disassembly (CPU) ............... 47 Save Options . . . . . . . . . . . . . . . . . . . 65 Goto ....................... 48 Restore Options. . . . . . . . . . . . . . . . . . 66 Origin ...................... 48 Window menu ................... 66 Follow ...................... 49 Zoom ........................ 67 Previous . . . . . . . . . . . . . . . . . . . . . 49 Next. ........................ 67 View Source . . . . . . . . . . . . . . . . . . 49 Next Pane . . . . . . . . . . . . . . . . . . . . . 67 Mixed ...................... 49 Size/Move ..................... 67 Text File ...................... 50 Iconize/Restore .................. 67 The File window SpeedMenu . . . . . . . . 50 Close ........................ 67 Goto ....................... 50 Undo Close . . . . . . . . . . . . . . " . . . . . 67 Search ...................... 50 User Screen . . . . . . . . . . . . . . . . . . . . 68 Next ....................... 50 The open window list . . . . . . . . . . . . . . 68 File ........................ 51 Help menu . . . . . . . . . . . . . . . . . . . . . 68 Edit ........................ 51 Index ........................ 68 Coverage ..................... 51 Previous Topic .................. 68 Add All Modules (left pane) ......... 52 Help on Help . . . . . . . . . . . . . . . . . . . 68 Remove All Modules (left pane) ....... 52 Add Module (left pane) ............ 52 Chapter3 Remove Module (left pane). ......... 52 Profiling strategies 69 Delete This Item (left pane) .......... 52 Display (right pane) .............. 52 Preparing to profile . . . . . . . . . . . . . . . . . 70 Position (right pane) .............. 53 Adjusting your program . . . . . . . . . . . . . 70 Module (right pane) .............. 53 Compiling your program. . . . . . . . . . . . . 71 Runmenu ...................... 54 Setting profile areas . . . . . . . . . . . . . . . . 71 Run ......................... 54 What level of detail do you need? ....... 72 Program Reset . . . . . . . . . . . . . . . . . . 54 Adding areas . . . . . . . . . . . . . . . . . . . 73 Arguments .................... 54 What type of data do you need? ........ 73 Statistics menu . . . . . . . . . . . . . . . . . . . 55 When should data collection start? ...... 74 Callers ....................... 55 How do you want time data grouped? .... 74 Files ......................... 56 Which data do you want to look at? ...... 74 Interrupts . . . . . . . . . . . . . . . . . . . . . 56 Profiling your program . . . . . . . . . . . . . . 75 Overlays . . . . . . . . . . . . . . . . . . . . . . 56 Focusing the profile session . . . . . . . . . . . 75 Profiling Options. . . . . . . . . . . . . . . . . 56 Testing algorithms ................ 76 Accumulation. . . . . . . . . . . . . . . . . . . 58 Verifying and testing programs . . . . . . . . 76 Disabling accumulation ............ 58 Timing execution and monitoring Delete All . . . . . . . . . . . . . . . . . . . . . 60 performance. . . . . . . . . . . . . . . . . . . 76 Save ........................ 60 Studying unfamiliar code . . . . . . . . . . . . 77 Saving Files . . . . . . . . . . . . . . . . . . . 60 Which analysis mode to use . . . . . . . . . . . 77 Restore ....................... 60 Active analysis . . . . . . . . . . . . . . . . . . 78 Print menu. . . . . . . . . . . . . . . . . . . . . . 61 Passive analysis . . . . . . . . . . . . . . . . . . 78 · Statistics . . . . . . . . . . . . . . . . . . . . . . 61 Passive versus active analysis . . . . . . . . 79 Module ...................... 61 Coverage analysis . . . . . . . . . . . . . . . . 79 Options ...................... 62 Speeding up profiling . . . . . . . . . . . . . . . 79 Options menu. . . . . . . . . . . . . . . . . . . . 62 Improving statistical accuracy . . . . . . . . . . 79 Macros ....................... 63 Insufficient data. . . . . . . . . . . . . . . . . . 80 Create ...................... 63 Resonance . . . . . . . . . . . . . . . . . . . . . 80 Stop Recording . . . . . . . . . . . . . . . . . 63 Some tips for profiling overlays . . . 80 Remove ..................... 63 Profiling object-oriented programs ....... 81 Delete All . . . . . . . . . . . . . . . . . . . . 63 ii Interpreting and applying the profile results .. 81 The default colors . . . . . . . . . . . . . . . . .103 Analyzing profile data . . . . . . . . . . . . . . . 81 Setting Turbo Profiler display parameters . . 103 Execution Profile window . . . . . . . . . . . 82 Display Swapping . . . . . . . . . . . . . . . . .103 Callers window. . . . . . . . . . . . . . . . . . 82 Screen Lines. . . . . . . . . . . . . . . . . . . . .104 Overlays window . . . . . . . . . . . . . . . . 82 Fast Screen Update . . . . . . . . . . . . . . . .104 Interrupts window. . . . . . . . . . . . . . . . 82 Permit43/50Lines ................1 04 Files window . . . . . . . . . . . . . . . . . . . 82 Full Graphics Saving . . . . . . . . . . . . . . .104 Coverage window . . . . . . . . . . . . . . . . 82 Tab Size . . . . . . . . . . . . . . . . . . . . . . .104 Filtering collected data. . . . . . . . . . . . . . . 83 User Screen Updating ...............1 05 Revising your program . . . . . . . . . . . . . . 84 Turbo Profiler options . . . . . . . . . . . . . . 105 Modifying data structures . . . . . . . . . . . 84 The Directories dialog box . . . . . . . . . . . .105 Storing precomputed resuits . . . . . . . . . . 85 The User Input and Prompting dialog box . .105 Caching frequently accessed data . . . . . . . 85 History List Length ................1 06 Evaluating data as needed . . . . . . . . . . . 85 Interrupt Key ...................1 06 Optimizing existing code . . . . . . . . . . . . 85 Mouse Enabled ..................1 06 Wrapping it up . . . . . . . . . . . . . . . . . . . 86 Beep on Error . . . . . . . . . . . . . . . . . . .106 Control Key Shortcuts ..............1 06 Chapter4 The Miscellaneous Options dialog box . . . . .106 Inside the profiler 87 Printer Output ..................1 07 NMI Intercept. ..................1 07 Area boundaries . . . ~ . . . . . . . . . . . . . . 88 Ignore Case of Symbols . . . . . . . . . . . . .107 Time and count collection . . . . . . . . . . . . . 88 International support ..............1 07 Showing routine call overhead . . . . . . . . . . 89 DOS Shell Swap Size (Kb) ............1 08 Who pays forloops? . . . . . . . . . . . . . . . . 89 Remote type. . . . . . . . . . . . . . . . . . . .108 Multiple return statements . . . . . . . . . . . . 91 Remote Link Port. . . . . . . . . . . . . . . . .108 Disabling often-called functions . . . . . . . . . 91 Link Speed .....................1 08 Logging callers . . . . . . . . . . . . . . . . . . . 92 Network local name ...............1 08 Sampling vs. counting . . . . . . . . . . . . . . . 93 Network remote name ..............1 08 Profiler memory use . . . . . . . . . . . . . . . . 94 Setting the mode for display . . . . . . . . . . .108 Default . . . . . . . . . . . . . . . . . . . . .108 Appendix A Color ......................1 09 Turbo Profiler's command-line Black and White . . . . . . . . . . . . . . . .109 Monochrome. . . . . . . . . . . . . . . . .. 109 options 95 LCD .......................1 09 The command-line options . . . . . . . . . . . . 95 When you're through.... . . . . . . . . . . . . . 109 Batch mode (-b) ................... 96 Saving changes. . . . . . . . . . . . . . . . . . .109 Configuration file (-c) ............... 97 Save Configuration File .............1 09 Display update (-d) ................ 97 Modify TPROF.EXE ...............1 09 Help (-hand-?) .................. 97 Exiting TFINST. . . . . . . . . . . . . . . . . . .110 Session-state saving (-jn) ............. 98 Command-line options and TFINST Mouse support (-p) . . . . . . . . . . . . . . . . 98 equivalents . . . . . . . . . . . . . . . . . . . . 110 Remote profiling (-r) ................ 98 AppendixC Source code and symbols (-s). . . . . . . . . . . 98 Video hardware (-v) ................ 99 Remote Profiling 113 AppendixB Hardware and software requirements. . . . . 114 Profiling remote OOS applications. . . . . . . 114 Customizing Turbo Profiler 101 Setting up the remote system . . . . . . . . . .114 Running TFINST . . . . . . . . . . . . . . . . . 101 Configuring TFREMOTE. . . . . . . . . . . . .115 Setting the screen colors . . . . . . . . . . . . . 102 Customizing TFREMOTE. . . . . . . . . . . .115 Customizing screen colors . . . . . . . . . . . 102 The remote DOS driver . . . . . . . . . . . . . .116 Windows . . . . . . . . . . . . . . . . . . . . .102 Starting the remote serial driver ........1 16 Dialog boxes and menus . . . . . . . . . ... 102 Starting the remote LAN driver ........1 16 Screen ....................... 103 Establishing the remote DOS link . . . . . . . .117 iii Serial connection ................. 117 Configuring TPROFW . . . . . . . . . . . . . . 126 LAN connection . . . . . . . . . . . . . . . .. 117 Using TPROFW command-line options . . . .127 Profiling remote Windows applications . . . 118 Using TFINST with TPROFW . . . . . . . . .. 127 Setting up the remote system . . . . . . . . . . 118 UsingTPROFW .................. 128 Configuring WREMOTE . . . . . . . . . . . . 118 Profiling window procedures . . . . . . . . . .128 Serial configuration . . . . . . . . . . . . . . . 119 The Window Procedure Messages LAN configuration. . . . . . . . . . . . . . .. 119 dialog box . . . . . . . . . . . . . . . . . . . .129 WREMOTE command-line options. . . . .. 120 Profiling dynamic-link libraries (DLLs) ....1 30 Starting the remote Windows driver . . . . . 120 TPROFW error messages . . . . . . . . . . . . 131 Establishing the remote Windows link . . . . 120 LAN connection . . . . . . . . . . . . . . . . .121 AppendixE Loading programs onto the remote system . 121 Prompts and error messages 133 Remote profiling sessions . . . . . . . . . . . . 121 Turbo Profiler prompts. . . . . . . . . . . . . . 133 Troubleshooting. . . . . . . . . . . . . . . . . . 122 Turbo Profiler error messages .......... 135 TFREMOTE messages . . . . . . . . . . . . . . 122 WREMOTE messages . . . . . . . . . . . . . . 123 Index 141 AppendixD Turbo Profiler for Windows 125 Installing TPROFW. . . . . . . . . . . . . . . . 126 Installing TDDEBUG.386 . . . . . . . . . . . . 126 iv Tables 2.1 Menu hot keys ................... 21 Al Turbo Profiler command-line options ..... 96 2.2 Manipulating windows . . . . . . . . . . . . . 21 B.1 Command-line options and TFINST 2.3 Turbo Profile session-state saving options . . 26 equivalents . . . . . . . . . . . . . . . . . . . . 110 2.4 Summary of Turbo Profiler windows ..... 27 B.2 TFINST.EXE options . . . . . . . . . . . . . . 111 2.5 Summary of interrupt statistic formats . . . . 42 C.1 TFREMOTE command-line options ..... 115 3.1 Ways of using a profiler . . . . . . . . . . . . . 75 C.2 WREMOTE command-line options . 120 3.2 SpeedMenu commands for filtering D.1 TPROFW command-line ootions . . 127 collected statistics . . . . . . . . . . ~. . . . . . 83 D.2 Window's message classes'. . . . . . . 130 v Figures 1.1 Turbo Profiler with PRIMEO loaded ....... 7 2.11 The Areas window . . . . . . . . . . . . . . . . 44 1.2 Program statistics, PRIMEO . . . . . . . . . . . . 8 2.12 The Area Options dialog box . . . . . . . . . .45 1.3 The Display Options dialog box . . . . . . . . . 9 2.13 The Routines window ............. .46 1.4 Counts display in the Execution Profile 2.14 The Disassembly (CPU) window ....... .47 window ........................ 9 2.15 The Coverage window . . . . . . . . . . . . . . 51 2.1 The Load A New Program to Profile 2.16 The Coverage Display dialog box. ....... 52 dialog box ..................... 24 2.17 The Coverage window, listing blocks by 2.2 The Enter Program Name to Load routine ........................ 53 dialog box . . . . . . . . . . . . . . . . . . . . . 25 2.18 The Profiling Options dialog box . . . . . . . . 56 2.3 The Module window (zoomed) . . . . . . . . 28 2.19 The Display Options dialog box. ........ 64 2.4 The Area Options dialog box . . . . . . . . . . 30 2.20 The Save Configuration dialog box. . . . . . . 65 2.5 The Stack Trace dialog box . . . . . . . . . . . 32 B.1 Customizing colors for windows ....... 102 2.6 The Display Options dialog box . . . . . . . . 34 B.2 The Display Options dialog box. . . . . . . . 103 2.7 The Callers window, showing calls in B.3 The User Input and Prompting CALLTEST ..................... 37 dialog box . . . . . . . . . . . . . . . . . . . . . 106 2.8 The Overlays window . . . . . . . . . . . . . . 40 B.4 The Miscellaneous Options dialog box . . . 107 2.9 The Interrupts window . . . . . . . . . . . . . 41 C.1 WRSETUP main window and Settings 2.10 The Files Window ................ 42 dialog box . . . . . . . . . . . . . . . . . . . . . 119 vi Introduction Borland's Turbo Profiler is the missing link in your software development cycle. Once you have your code doing what you want, Turbo Profiler helps you do it faster and more efficiently. Turbo Profiler is a performance analyzer, a software tool that measures your program's performance by finding • Where your program spends its time • How many times a line executes • What lines have been executed • How many times a routine is called, and by which routines • What files your program accesses most and for how long Turbo Profiler also monitors critical computer resources, such as • Processor time • Disk access • Keyboard input • Printer output • Interrupt activity By monitoring vital activities and providing detailed statistical reports on every part of your program's performance, Turbo Profiler enables you to fine-tune your programs. By opening up the inside of your program and exposing its most intricate operations from execution times to statement counts, from interrupt calls to file access activities Turbo Profiler helps you polish your code and speed up your programs. Turbo Profiler surpasses other profilers on the market both in power and ease of use by providing the following features: • Interactive profiling quickly reveals inefficient code in a program. • Lets you read and edit any text file during profiling sessions. • Profiles any size program that runs under DOS or Windows. • Handles programs written using Borland's C++ compilers and Turbo Assembler. • Provides an easy-to-use interface with multiple overlapping windows, mouse support, and context-sensitive help. Introduction 1