#[non_exhaustive]pub struct Stats { /* private fields */ }Expand description
The Halstead metric suite.
Implementations§
Source§impl Stats
impl Stats
Sourcepub fn unique_operators(&self) -> u64
pub fn unique_operators(&self) -> u64
Returns η1, the number of distinct operators
Sourcepub fn total_operators(&self) -> u64
pub fn total_operators(&self) -> u64
Returns N1, the number of total operators
Sourcepub fn unique_operands(&self) -> u64
pub fn unique_operands(&self) -> u64
Returns η2, the number of distinct operands
Sourcepub fn total_operands(&self) -> u64
pub fn total_operands(&self) -> u64
Returns N2, the number of total operands
Sourcepub fn length(&self) -> u64
pub fn length(&self) -> u64
Returns the program length
Computed as N = N1 + N2, the sum of Self::total_operators and
Self::total_operands.
Sourcepub fn estimated_program_length(&self) -> f64
pub fn estimated_program_length(&self) -> f64
Returns the calculated estimated program length
Computed as N^ = n1 * log2(n1) + n2 * log2(n2), where n1 is
Self::unique_operators and n2 is Self::unique_operands. Each term is
treated as 0 when its unique count is 0.
Sourcepub fn purity_ratio(&self) -> f64
pub fn purity_ratio(&self) -> f64
Returns the purity ratio
Computed as PR = N^ / N, the ratio of
Self::estimated_program_length to Self::length.
Sourcepub fn vocabulary(&self) -> u64
pub fn vocabulary(&self) -> u64
Returns the program vocabulary
Computed as n = n1 + n2, the sum of Self::unique_operators and
Self::unique_operands.
Sourcepub fn volume(&self) -> f64
pub fn volume(&self) -> f64
Returns the program volume.
Computed as V = N * log2(n), where N is Self::length and n
is Self::vocabulary. Returns 0 when the vocabulary is <= 1,
since log2 would be non-positive.
Unit of measurement: bits
Sourcepub fn difficulty(&self) -> f64
pub fn difficulty(&self) -> f64
Returns the estimated difficulty required to program
Computed as D = (n1 / 2) * (N2 / n2), where n1 is
Self::unique_operators, N2 is Self::total_operands, and n2 is
Self::unique_operands.
Sourcepub fn level(&self) -> f64
pub fn level(&self) -> f64
Returns the estimated level of difficulty required to program
Computed as L = 1 / D, the reciprocal of Self::difficulty.
Sourcepub fn effort(&self) -> f64
pub fn effort(&self) -> f64
Returns the estimated effort required to program
Computed as E = D * V, the product of Self::difficulty and
Self::volume.
Sourcepub fn time(&self) -> f64
pub fn time(&self) -> f64
Returns the estimated time required to program.
Computed as T = E / 18, where E is Self::effort and 18 is
the Stroud number (see the divisor rationale below).
Unit of measurement: seconds
Sourcepub fn bugs(&self) -> f64
pub fn bugs(&self) -> f64
Returns the estimated number of delivered bugs.
This metric represents the average amount of work a programmer can do without introducing an error.
Computed as B = E^(2/3) / 3000, where E is Self::effort. This
is the effort-based variant of Halstead’s delivered-bugs estimate
rather than the more commonly cited volume-based form B = V / 3000;
it matches the formula used by upstream rust-code-analysis.