JavaScript Editor js editor     Web development 

Main Page

Later in the development process, you might want to refine your code for performance and ensure that you've adequately tested the code by logging code coverage information.

Code coverage gives you information about which lines of code have been executed and how long it took to execute them. This information can help you identify areas of code that aren't being executed and therefore aren't being tested, as well as areas of the code that you might want to fine tune for performance.

You can toggle code coverage on and off by clicking the Code Coverage toolbar button in the Debugger Window. If you toggle code coverage on, the Coverage Dialog Box opens so that you can specify a file to save the coverage information to.

You can also toggle coverage logging on and off programmatically by using the SET COVERAGE TO command. You could, for example, include the following command in your application just before a piece of code you want to investigate:

В Copy Code

After the section of code you want to log coverage for, you could include the following command to set code coverage off:

В Copy Code

When you've specified a file for the coverage information, switch to the main Visual FoxPro window and run your program, form, or application. For every line of code that is executed, the following information is written to the log file:

The easiest way to extract information from the log file is to convert it into a table so that you can set filters, run queries and reports, execute commands, and manipulate the table in other ways.

The Coverage Profiler Application creates a cursor from the data generated in coverage logging and uses this cursor in a window for easy analysis.


The following program converts the text file created by the coverage log into a table:

В Copy Code
cFileName = GETFILE('DBF')
IF EMPTY(cFileName)

CREATE TABLE (cFileName) ;
   (duration n(7,3), ;
   class c(30), ;
   procedure c(60), ;
   line i, ;
   file c(100))

See Also

JavaScript Editor js editor     Web development