Skip to main content

TimedExecution

Struct TimedExecution 

Source
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

Source

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");
Source

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);
Source

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§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.