INNER CODE UNIT · Rust
new
tangle-network/blueprint · crates/blueprint-profiling/src/lib.rs:96
pub fn new(blueprint_name: impl Into<String>) -> Self {
Self {
blueprint_name: blueprint_name.into(),
profiled_at: chrono::Utc::now().to_rfc3339(),
jobs: std::collections::HashMap::new(),
}
}
/// Add a job profile
pub fn add_job(&mut self, job_id: u32, profile: JobProfile) {
self.jobs.insert(job_id, profile);
}
/// Save profiles to a JSON file
///
/// Typically saved to `target/blueprint-profiles.json` in the blueprint workspace.
pub fn save_to_file(&self, path: impl AsRef<std::path::Path>) -> Result<(), ProfilingError> {
let json = serde_json::to_string_pretty(self).map_err(|e| {