No, I'm not talking about racial profiling. The term "profiling" is used in computers to describe the process of analyzing an application for performance reasons - to locate and reduce or eliminate bottlenecks. Profiling an application can be as simple as making changes to your code and using a stop watch to time executions to improve performance. Fortunately there is a much better way, there are tools to help you profile your application. Below I'll tell you have to use Visual Studio 2005 to profile your application. Note that most every version of Visual Studio has a Profiler, and the use of that Profiler may very. This is only for Visual Studio 2005.
For starters the Profiler is only an option on the highest levels of Visual Studio - I believe they call it Team Suite. You also have to select the Profiler option during Visual Studio installation. From your Visual Studio IDE, select the Tools menu and look for a "Performance Tools" option. If you don't see it then you didn't install the Profiler and/or you don't have a level of Visual Studio high enough.
If you have the "Performance Tools" menu option then you've crossed the first hurdle. Next you need to select a Release build of your project. You can profile a Debug build, but you'll get a lot of "noise" so best to use a Release build. You need to do two things before you compile your code. First, enable Symbols for your Release build. Second, you need to add the "/PROFILE" switch to the linker. This option must be added manually in the "Additional options" section. The /PROFILE switch instructs the linker to generate output that is friendly to the instrumenter.
At this point you can use the "Performance Tools" menu option to create a profile session. To profile your application you must run it from within Visual Studio, and you must use the "launch" button in the profiler view.
There is one more gotcha. If your application is more than a single EXE, if it contains DLLs, the Profiler will NOT traverse down into those DLLs which is probably what you want it to do. To profile your entire application including DLLs there is an additional step. You have to manually instrument your DLL files. To do this open a command prompt. The command is "vsinstr.exe a.dll" Note that when you instrument a file is generates a new PDB file.
Happy profiling!
No comments:
Post a Comment