ass_core/analysis/events/scoring/impact.rs
1//! Performance impact categorization for complexity scores.
2//!
3//! Defines the [`PerformanceImpact`] category enum and the mapping from a
4//! numerical complexity score to a categorical rendering impact level used
5//! for rendering optimization decisions.
6
7/// Performance impact category for rendering complexity
8#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord)]
9pub enum PerformanceImpact {
10 /// Minimal impact - simple static text
11 Minimal,
12 /// Low impact - basic formatting
13 Low,
14 /// Medium impact - animations or complex styling
15 Medium,
16 /// High impact - many animations or large text
17 High,
18 /// Critical impact - may cause performance issues
19 Critical,
20}
21
22/// Determine performance impact category from complexity score
23///
24/// Maps numerical complexity scores to categorical performance impact levels
25/// for easier rendering optimization decisions.
26///
27/// # Arguments
28///
29/// * `complexity_score` - Overall complexity score (0-100)
30///
31/// # Returns
32///
33/// Performance impact category for rendering optimization
34///
35/// # Example
36///
37/// ```rust
38/// # use ass_core::analysis::events::scoring::{get_performance_impact, PerformanceImpact};
39/// let impact = get_performance_impact(75);
40/// assert_eq!(impact, PerformanceImpact::High);
41/// ```
42#[must_use]
43pub const fn get_performance_impact(complexity_score: u8) -> PerformanceImpact {
44 match complexity_score {
45 0..=20 => PerformanceImpact::Minimal,
46 21..=40 => PerformanceImpact::Low,
47 41..=60 => PerformanceImpact::Medium,
48 61..=80 => PerformanceImpact::High,
49 _ => PerformanceImpact::Critical,
50 }
51}