Reading the profile

Merge

llvm-profdata merge -sparse work/cov/prof/*.profraw -o work/cov/ep.profdata
llvm-profdata merge -sparse work/cov/ep.profdata work/cov/tests.profdata -o work/cov/all.profdata   # a union

A .profraw with continuous mode is the size of the counters (about 8 MB for scarletnx here), whatever ran. -sparse drops the functions that never ran from the merged file.

Reports by file and by folder

X='(\.cache/|/build/|/usr/)'      # CPMUtil's sources, generated files, the system's headers
llvm-cov report build/cov/scarletnx -instr-profile=work/cov/ep.profdata -ignore-filename-regex="$X" \
    > work/cov/ep-report.txt
llvm-cov report build/cov/scarletnx -instr-profile=work/cov/ep.profdata -show-functions src/nx/hle/svc/svc.c

The report has a row per file with regions, functions, lines and branches, each run and missed. Its paths drop the common prefix (nx/hle/svc/svc.c). The per-folder table above is that report summed:

awk 'NR>2 && NF>=10 && $1 ~ /\// { n = split($1, p, "/"); d = p[1]; if (n > 2) d = d "/" p[2];
     if (n > 3 && p[1] == "nx") d = d "/" p[3]; L[d] += $8; M[d] += $9 }
     END { for (d in L) printf "%6.1f%% %7d %s\n", L[d] ? 100 * (L[d] - M[d]) / L[d] : 0, L[d], d }' \
    work/cov/ep-report.txt | sort -k3

A folder at 0% with many lines is a part the workload never enters: the GUI, the other drivers (3ds, vita, nds, android), glslc. That is expected for an Amberlith run; it is the tests' job.

Line by line

llvm-cov show build/cov/scarletnx -instr-profile=work/cov/ep.profdata -format=html -output-dir=work/cov/html \
    -ignore-filename-regex="$X" -show-branches=count -show-line-counts-or-regions
llvm-cov export build/cov/scarletnx -instr-profile=work/cov/ep.profdata -format=lcov > work/cov/ep.lcov

The HTML has an index by file, and each file with its counts in the margin: a red line never ran, and a branch shows how many times each side was taken. -format=lcov feeds genhtml or an editor's coverage gutter (VS Code's Coverage Gutters, for example). llvm-cov export without -format writes JSON with every function and its count, which the scripts below read: about 100 MB for this run, even with -skip-expansions, which leaves out the macro expansions' regions.


Made from docs/dev/coverage.md at 69237645142c. GPL-3.0-or-later.