Skip to main content

stylus_trace_core/diff/
mod.rs

1//! Profile diff generation and threshold checking.
2//!
3//! This module compares two Profile JSONs (baseline vs target) and produces
4//! delta reports with threshold violation detection.
5//!
6//! # Example
7//! ```ignore
8//! use stylus_trace_core::diff::{generate_diff, load_thresholds};
9//! use stylus_trace_core::output::json::read_profile;
10//!
11//! let baseline = read_profile("baseline.json")?;
12//! let target = read_profile("target.json")?;
13//! let diff = generate_diff(&baseline, &target)?;
14//!
15//! let thresholds = load_thresholds("thresholds.toml")?;
16//! let violations = check_thresholds(&diff, &thresholds);
17//! ```
18
19mod analyzer;
20mod engine;
21mod normalizer;
22mod output;
23mod schema;
24mod threshold;
25
26// Public API exports
27pub use analyzer::analyze_profile;
28pub use engine::generate_diff;
29pub use normalizer::{calculate_gas_delta, calculate_hostio_type_changes, safe_percentage};
30pub use output::render_terminal_diff;
31pub use schema::{
32    Deltas, DiffReport, DiffSummary, GasDelta, HostIOTypeChange, HostIoDelta, HotPathComparison,
33    HotPathsDelta, ProfileMetadata, ThresholdViolation,
34};
35pub use threshold::{
36    check_gas_thresholds, check_thresholds, create_summary, load_thresholds, GasThresholds,
37    HostIOThresholds, HotPathThresholds, ThresholdConfig,
38};
39
40pub use crate::utils::error::DiffError;