Coverage Analysis

From wiki.visual-prolog.com

Revision as of 13:01, 20 October 2008 by Thomas Linder Puls (talk | contribs) (First)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

The coverage analysis gives information about which predicates that have been called during execution of the program. The coverage analysis program reads the '.deb' files to get information about the set of classes and predicates in the program and the coverage files to get information about which predicates that have been called during execution of the program.

Coverage Set

A Coverage set is the set of predicates called during a test or other run. It is saved in a coverage file.


What to do?

Compile the program with option /profile:min.

Insert the following code in the goal. This will start the profiling and write the resulting coverage file with a name that depends on the time. If you want to place the coverage file somewhere different from the exe folder you should change the code to reflect that.

clauses
    run():-
        profileCount::start(),
        try
            TaskWindow = taskWindow::new(),
            TaskWindow:show()
        finally
            profileCount::stop(),
            if profileCount::getEntry_nd(_,_,_), !  then
                Now = time::new(),
                CoverageFileName = Now:format("yyyyMMddhhmmss'.coverage'"),
                Stream = outputStream_file::create(CoverageFileName),
                profileCount::printToCSV(Stream),
                Stream:close()
            end if
        end try.

Run the coverage tool and 'open' the project file. The Coverage Analysis will then

  1. search for all the .deb files and collect information about all predicate implementations
  2. search for the .coverage files and collect information about which predicates have been called.
  3. display a tree with information about coverage.

For this to work

  1. The program must be compiled so the .deb files are present.
  2. The deb files and the coverage files must be placed i a sub-folder to the project folder.