cu_profiler_core/lib.rs
1//! `cu-profiler-core` — the Solana compute-intelligence engine.
2//!
3//! This crate owns the domain model, the Solana log parser, the CPI call-tree
4//! and scope-marker analysis, the budget policy engine, baselines, confidence
5//! scoring, and diagnostics. It depends on no CLI code and no live Solana
6//! runtime by default: the [`backend::RecordedLogsBackend`] drives the entire
7//! pipeline from logs, which is how the parser, reports and CI logic are
8//! developed and tested.
9//!
10//! # Honesty about limitations
11//! - Scope/function attribution requires explicit markers; there is no automatic
12//! source-line profiling.
13//! - `program-test` results may differ from mainnet runtime conditions.
14//! - Baselines are only valid when their [`baseline::Fingerprint`] matches.
15//!
16//! # Example
17//! ```
18//! use cu_profiler_core::backend::RecordedLogsBackend;
19//! use cu_profiler_core::metadata::RunMetadata;
20//! use cu_profiler_core::scenario::Scenario;
21//! use cu_profiler_core::Profiler;
22//!
23//! let mut backend = RecordedLogsBackend::new();
24//! backend.insert_blob(
25//! "swap",
26//! "Program P invoke [1]\nProgram P consumed 1000 of 200000 compute units\nProgram P success",
27//! true,
28//! );
29//! let report = Profiler::new().run(
30//! &backend,
31//! &[Scenario::new("swap")],
32//! None,
33//! RunMetadata::recorded(cu_profiler_core::VERSION),
34//! );
35//! assert_eq!(report.scenarios[0].measurement.total_cu, 1000);
36//! ```
37#![forbid(unsafe_code)]
38#![warn(missing_docs)]
39
40#[cfg(feature = "anchor")]
41pub mod anchor;
42pub mod backend;
43pub mod baseline;
44pub mod budget;
45pub mod confidence;
46pub mod config;
47pub mod diagnostics;
48pub mod error;
49pub mod metadata;
50pub mod model;
51pub mod parser;
52pub mod profiler;
53pub mod program_registry;
54pub mod scenario;
55
56pub use error::{Error, Result};
57pub use profiler::Profiler;
58
59/// The version of `cu-profiler-core`.
60pub const VERSION: &str = env!("CARGO_PKG_VERSION");