Using FileMon

FileMon is a great utility if you need to debug performance problems in a Visual FoxPro application. After launching FileMon.EXE as an administrator change the filter to "VFP9.EXE" or the name of your application. When you now run your application, you can see all disk activities in your application.
FileMon is pretty good at telling you what went wrong. However, it doesn't help you to relate this with the actual line numbers in your code. To achieve this I use markers in my Visual FoxPro application. A marker looks like this:


=FILE("MyClass.MyMethod.BeforeScan")

That is, I check for the existence of a not existing file. In FileMon this line produces output similar to the following:


11:14:08.182 vfp9.exe:2776 FASTIO_QUERY_OPEN
C:\DOCUMENTS AND SETTINGS\CHRISTOF\MY
DOCUMENTS\PROJECTS\lib\MyClass.MyMethod.BeforeScan
FILE NOT FOUND Attributes: Error

Now I can search for my markers in FileMon. I can be confident that all activities between two markers have been caused by the code between the two markers. By adding and moving markers I can quickly identify the lines that cause most traffic in an application.