Previous: , Up: Programming Tools   [Contents][Index]

5.24.11 Code Coverage and Execution Frequency

If you run extensive tests on your code, you often want to figure out if the tests exercise all parts of the code. This is called (test) coverage. The file coverage.fs contains tools for measuring the coverage as well as execution frequency.

Code coverage inserts counting code in every basic block (straight-line code sequence) loaded after coverage.fs. Each time that code is run, it increments the counter for that basic block. Later you can show the source file with the counts inserted in these basic blocks.

doc-.coverage doc-annotate-cov doc-cov% doc-.cover-raw

By default, the counts are shown in colour (using ANSI escape sequences), but you can use bw-cover to show them in parenthesized form without escape sequences.

doc-bw-cover doc-color-cover

You can save and reload the coverage counters in binary format, to aggregate coverage counters across several test runs.

doc-save-cov doc-load-cov doc-cov+