Skip to main content

Subject

Struct Subject 

Source
pub struct Subject {
Show 18 fields pub name: String, pub cmd: Vec<String>, pub prepare: Option<Vec<String>>, pub setup: Option<Vec<String>>, pub setup_dir: Option<PathBuf>, pub check: Option<Vec<String>>, pub version_cmd: Option<Vec<String>>, pub dir: Option<PathBuf>, pub env: BTreeMap<String, String>, pub vars: BTreeMap<String, String>, pub when: Option<String>, pub runs: Runs, pub auto: AutoRuns, pub warmup: u32, pub counters: bool, pub allocations: bool, pub ok_exit_codes: Vec<i32>, pub metrics: BTreeMap<String, MetricSource>,
}
Expand description

A subject with every default applied, ready to measure.

Fields§

§name: String

Recorded as Record::tool.

§cmd: Vec<String>§prepare: Option<Vec<String>>§setup: Option<Vec<String>>

Run once before the subject’s first sample. Always from the directory holding tak.toml, never from dir; see Subject::anchor.

§setup_dir: Option<PathBuf>

Where setup runs: set by Subject::anchor to the directory holding tak.toml. None runs it in tak’s own working directory.

§check: Option<Vec<String>>

Run after every timed sample, untimed. Exit 0 means the sample passed.

§version_cmd: Option<Vec<String>>

Run once, untimed, after setup and before the first warmup; its first line of output is the version exported for this subject. See crate::measure::interleaved_with_versions.

§dir: Option<PathBuf>

Relative to tak.toml; the caller resolves it.

§env: BTreeMap<String, String>§vars: BTreeMap<String, String>

Template values from vars tables, used by crate::template.

§when: Option<String>

Measured only when this holds; see crate::condition.

§runs: Runs§auto: AutoRuns

The limits Runs::Auto works within.

§warmup: u32§counters: bool§allocations: bool

Count heap allocations under DHAT. Recorded and reported, never gated.

§ok_exit_codes: Vec<i32>

Exit codes a timed or warmup sample may end with and still count. Never empty. A death by signal fails whatever this holds, and setup and prepare are always held to exit 0.

§metrics: BTreeMap<String, MetricSource>

Custom metrics by name, recorded beside the timings. Empty unless a layer declares some.

Implementations§

Source§

impl Subject

Source

pub fn anchor(&mut self, root: &Path)

Resolve paths against root, the directory holding tak.toml.

dir becomes the working directory, but a relative program path — one containing a /, like ./target/release/mycli — is resolved against root, not dir. Otherwise giving a subject a fixture directory would make the project’s own binary unfindable. A bare name is left for PATH lookup, and arguments are never touched.

setup is the exception to dir: it runs in root itself. Its usual job is to create or recreate dir — a clone, a generated project — and a command cannot sensibly start inside a directory that does not exist yet or that it is about to delete. Running it where dir is written relative to also means the same path works as one of its arguments. Choosing between the two by whether dir exists would give a setup a different working directory on its second run than on its first.

Trait Implementations§

Source§

impl Clone for Subject

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Subject

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl PartialEq for Subject

Source§

fn eq(&self, other: &Self) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for Subject

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

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

Source§

type Error = !

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

fn try_from(value: U) -> Result<T, !>

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.