pub struct TracyTrace { /* private fields */ }Expand description
In-memory collection of Tracy trace records.
Holds zones, text messages, and numeric plot entries that can be exported to a CSV file understood by Tracy-compatible tooling.
§Example
use trustformers_debug::export::tracy::TracyTrace;
let trace = TracyTrace::new();
assert!(trace.is_empty());Implementations§
Source§impl TracyTrace
impl TracyTrace
Sourcepub fn total_records(&self) -> usize
pub fn total_records(&self) -> usize
Returns the total number of records (zones + messages + plots).
Sourcepub fn add_zone(&mut self, zone: TracyZone)
pub fn add_zone(&mut self, zone: TracyZone)
Appends a profiling zone.
§Example
use trustformers_debug::export::tracy::{TracyTrace, TracyZone};
let mut trace = TracyTrace::new();
trace.add_zone(TracyZone {
name: "forward".to_string(),
timestamp_ns: 0,
duration_ns: 1000,
thread_id: 0,
});
assert_eq!(trace.zones().len(), 1);Sourcepub fn add_message(&mut self, msg: &str, timestamp_ns: u64)
pub fn add_message(&mut self, msg: &str, timestamp_ns: u64)
Appends a text message with a timestamp.
§Example
use trustformers_debug::export::tracy::TracyTrace;
let mut trace = TracyTrace::new();
trace.add_message("epoch started", 1_000_000);
assert_eq!(trace.messages().len(), 1);Sourcepub fn add_plot(&mut self, name: &str, value: f64, timestamp_ns: u64)
pub fn add_plot(&mut self, name: &str, value: f64, timestamp_ns: u64)
Appends a named numeric plot value with a timestamp.
§Example
use trustformers_debug::export::tracy::TracyTrace;
let mut trace = TracyTrace::new();
trace.add_plot("loss", 0.42, 2_000_000);
assert_eq!(trace.plots().len(), 1);Sourcepub fn export_to_file(&self, path: &Path) -> Result<()>
pub fn export_to_file(&self, path: &Path) -> Result<()>
Writes the trace to path in Tracy CSV format.
Records are emitted in the order: zones (each zone becomes a
ZoneBegin / ZoneEnd pair), messages, then plots.
§Errors
Returns an error if the file cannot be created or written.
§Example
use trustformers_debug::export::tracy::TracyTrace;
let trace = TracyTrace::new();
trace.export_to_file(std::path::Path::new("/tmp/trace.csv")).unwrap();Trait Implementations§
Source§impl Debug for TracyTrace
impl Debug for TracyTrace
Source§impl Default for TracyTrace
impl Default for TracyTrace
Source§fn default() -> TracyTrace
fn default() -> TracyTrace
Returns the “default value” for a type. Read more
Source§impl From<&TracyTrace> for ProfilingTrace
impl From<&TracyTrace> for ProfilingTrace
Source§fn from(t: &TracyTrace) -> Self
fn from(t: &TracyTrace) -> Self
Converts to this type from the input type.
Auto Trait Implementations§
impl Freeze for TracyTrace
impl RefUnwindSafe for TracyTrace
impl Send for TracyTrace
impl Sync for TracyTrace
impl Unpin for TracyTrace
impl UnsafeUnpin for TracyTrace
impl UnwindSafe for TracyTrace
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§impl<T> Pointable for T
impl<T> Pointable for T
impl<T> Read<Exclusive, BecauseExclusive> for Twhere
T: ?Sized,
Source§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
Source§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
The inverse inclusion map: attempts to construct
self from the equivalent element of its
superset. Read moreSource§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
Checks if
self is actually part of its subset T (and can be converted to it).Source§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
Use with care! Same as
self.to_subset but without any property checks. Always succeeds.Source§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
The inclusion map: converts
self to the equivalent element of its superset.Source§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
Source§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
The inverse inclusion map: attempts to construct
self from the equivalent element of its
superset. Read moreSource§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
Checks if
self is actually part of its subset T (and can be converted to it).Source§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
Use with care! Same as
self.to_subset but without any property checks. Always succeeds.Source§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
The inclusion map: converts
self to the equivalent element of its superset.