Expand description
Profile diff generation and threshold checking.
This module compares two Profile JSONs (baseline vs target) and produces delta reports with threshold violation detection.
§Example
ⓘ
use stylus_trace_core::diff::{generate_diff, load_thresholds};
use stylus_trace_core::output::json::read_profile;
let baseline = read_profile("baseline.json")?;
let target = read_profile("target.json")?;
let diff = generate_diff(&baseline, &target)?;
let thresholds = load_thresholds("thresholds.toml")?;
let violations = check_thresholds(&diff, &thresholds);Re-exports§
pub use crate::utils::error::DiffError;
Structs§
- Deltas
- All calculated deltas
- Diff
Report - Complete diff report comparing baseline and target profiles
- Diff
Summary - Summary of diff results
- GasDelta
- Gas usage delta
- GasThresholds
- Gas-related thresholds
- HostIO
Thresholds - HostIO-related thresholds
- HostIO
Type Change - Change in a specific HostIO type
- Host
IoDelta - HostIO statistics delta
- HotPath
Comparison - Comparison of a single hot path present in both profiles
- HotPath
Thresholds - Hot path thresholds
- HotPaths
Delta - Hot paths comparison
- Profile
Metadata - Metadata extracted from a profile for comparison
- Threshold
Config - Complete threshold configuration
- Threshold
Violation - A single threshold violation
Functions§
- analyze_
profile - Analyze a profile for qualitative insights
- calculate_
gas_ delta - Calculate gas delta between two profiles
- calculate_
hostio_ type_ changes - Calculate changes for each HostIO type
- check_
gas_ thresholds - Check gas thresholds
- check_
thresholds - Check a diff report against thresholds and update violations
- create_
summary - Create summary based on violations
- generate_
diff - Generate a complete diff report comparing two profiles
- load_
thresholds - Load thresholds from a TOML file
- render_
terminal_ diff - Render a human-readable summary of a diff report for the terminal
- safe_
percentage - Calculate percentage change safely (handles division by zero)