pub struct TimedExecution { /* private fields */ }Expand description
Helper struct for timing command execution Helper for timing command execution and tracking results.
Preferred API for tracking commands. Automatically measures execution time
and records token savings. Use instead of the deprecated [track] function.
§Examples
ⓘ
use rtk::tracking::TimedExecution;
let timer = TimedExecution::start();
let input = execute_standard_command()?;
let output = execute_rtk_command()?;
timer.track("ls -la", "rtk ls", &input, &output);Implementations§
Source§impl TimedExecution
impl TimedExecution
Sourcepub fn start() -> Self
pub fn start() -> Self
Start timing a command execution.
Creates a new timer that starts measuring elapsed time immediately.
Call track or track_passthrough
when the command completes.
§Examples
use rtk::tracking::TimedExecution;
let timer = TimedExecution::start();
// ... execute command ...
timer.track("cmd", "rtk cmd", "input", "output");Sourcepub fn track(
&self,
original_cmd: &str,
rtk_cmd: &str,
input: &str,
output: &str,
)
pub fn track( &self, original_cmd: &str, rtk_cmd: &str, input: &str, output: &str, )
Track the command with elapsed time and token counts.
Records the command execution with:
- Elapsed time since
start - Token counts estimated from input/output strings
- Calculated savings metrics
§Arguments
original_cmd: Standard command (e.g., “ls -la”)rtk_cmd: RTK command used (e.g., “rtk ls”)input: Standard command output (for token estimation)output: RTK command output (for token estimation)
§Examples
use rtk::tracking::TimedExecution;
let timer = TimedExecution::start();
let input = "long output...";
let output = "short output";
timer.track("ls -la", "rtk ls", input, output);Sourcepub fn track_passthrough(&self, original_cmd: &str, rtk_cmd: &str)
pub fn track_passthrough(&self, original_cmd: &str, rtk_cmd: &str)
Track passthrough commands (timing-only, no token counting).
For commands that stream output or run interactively where output cannot be captured. Records execution time but sets tokens to 0 (does not dilute savings statistics).
§Arguments
original_cmd: Standard command (e.g., “git tag –list”)rtk_cmd: RTK command used (e.g., “rtk git tag –list”)
§Examples
use rtk::tracking::TimedExecution;
let timer = TimedExecution::start();
// ... execute streaming command ...
timer.track_passthrough("git tag", "rtk git tag");Auto Trait Implementations§
impl Freeze for TimedExecution
impl RefUnwindSafe for TimedExecution
impl Send for TimedExecution
impl Sync for TimedExecution
impl Unpin for TimedExecution
impl UnsafeUnpin for TimedExecution
impl UnwindSafe for TimedExecution
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