pub struct UsageTracker { /* private fields */ }Expand description
Thread-safe usage tracker for the test runner.
Implementations§
Source§impl UsageTracker
impl UsageTracker
Sourcepub fn record_llm_call(
&self,
endpoint_name: &str,
endpoint: &ResolvedEndpoint,
input_tokens: u64,
output_tokens: u64,
)
pub fn record_llm_call( &self, endpoint_name: &str, endpoint: &ResolvedEndpoint, input_tokens: u64, output_tokens: u64, )
Sourcepub fn record_flat_call(&self, endpoint_name: &str, endpoint: &ResolvedEndpoint)
pub fn record_flat_call(&self, endpoint_name: &str, endpoint: &ResolvedEndpoint)
Sourcepub fn current_test_snapshot(&self) -> UsageSnapshot
pub fn current_test_snapshot(&self) -> UsageSnapshot
Sourcepub fn global_snapshot(&self) -> UsageSnapshot
pub fn global_snapshot(&self) -> UsageSnapshot
Sourcepub fn per_test_snapshots(&self) -> Vec<(String, UsageSnapshot)>
pub fn per_test_snapshots(&self) -> Vec<(String, UsageSnapshot)>
Sourcepub fn reset_per_test(&self)
pub fn reset_per_test(&self)
Resets the per-test accumulator. Call at the start of each test.
§Panics
Panics if the mutex is poisoned.
Sourcepub fn commit_test(&self, test_name: &str)
pub fn commit_test(&self, test_name: &str)
Commits the current test’s usage to the global accumulator and stores it as a per-test snapshot.
§Panics
Panics if the mutex is poisoned.
Trait Implementations§
Auto Trait Implementations§
impl !Freeze for UsageTracker
impl RefUnwindSafe for UsageTracker
impl Send for UsageTracker
impl Sync for UsageTracker
impl Unpin for UsageTracker
impl UnsafeUnpin for UsageTracker
impl UnwindSafe for UsageTracker
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