File: code_coverage.rst

package info (click to toggle)
numba 0.61.2%2Bdfsg-2
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 17,316 kB
  • sloc: python: 211,580; ansic: 15,233; cpp: 6,544; javascript: 424; sh: 322; makefile: 173
file content (24 lines) | stat: -rw-r--r-- 1,318 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
===============================
Code Coverage for Compiled Code
===============================

Numba, a just-in-time compiler for Python, transforms Python code into machine 
code for optimized execution. This process, however, poses a challenge for 
traditional code coverage tools, as they typically operate within the Python 
interpreter and thus miss the lines of code compiled by Numba. To address this 
issue, Numba opts for a compile-time notification to coverage tools, rather than 
during execution, to minimize performance penalties. This approach helps prevent 
significant coverage gaps in projects utilizing Numba, without incurring 
substantial performance costs.

No additional effort is required to generate compile-time coverage data. By 
running a Numba application under the ``coverage`` tool 
(e.g. ``coverage run ...``), the compiler automatically 
detects the active coverage session and emits data accordingly. This mechanism 
ensures that coverage data is generated seamlessly, without the need for manual 
intervention.

The coverage data is emitted during the lowering phase, which involves the 
generation of LLVM-IR. This phase inherently excludes lines of code that are 
statically identified as dead code, ensuring that the coverage data accurately 
reflects the executable code paths.