Skip to main content

Store

Struct Store 

Source
pub struct Store { /* private fields */ }
Expand description

The directory baselines are kept in.

Implementations§

Source§

impl Store

Source

pub fn locate() -> Result<Self>

The store for the repository the current directory is in.

No fallback outside a repository. Anywhere else — a per-user data directory, the current directory — is either shared between unrelated projects, where one project’s before silently answers for another’s, or inside a tree that may be committed.

Source

pub fn at(dir: impl Into<PathBuf>) -> Self

A store rooted at dir, which need not exist yet.

Source

pub fn dir(&self) -> &Path

Source

pub fn list(&self) -> Result<Vec<String>>

Names of the saved baselines, sorted.

Source

pub fn load(&self, name: &str) -> Result<Baseline>

Load a baseline, failing when it does not exist or holds nothing.

Called before anything is measured: a mistyped name should cost a second, not a full run followed by an error.

Source

pub fn check_saveable(&self, name: &str) -> Result<()>

Fail now if saving under name would be refused later, so a run that cannot be saved is not measured first.

Source

pub fn save(&self, name: &str, records: &[Record]) -> Result<PathBuf>

Save records under name, returning the file written.

Replaces what the baseline held for each series in records and keeps every other series, so tak run --bench a --save-baseline x updates a without discarding the b a full run saved earlier. The same series key compare uses, runner included: a baseline saved with --runner on two classes keeps one series for each.

A line that does not parse at all — a hand edit — is kept as it is: readers skip it, and dropping it would destroy something someone wrote. A record from a newer schema refuses the save instead; see the comment where it is found.

Written to a temporary file and renamed into place, so an interrupted save leaves the previous baseline whole rather than half of either.

The read-modify-write holds an exclusive lock on a sibling lock file. Every worktree of a clone shares this directory, so two runs saving different benchmarks to one name at once is ordinary. Without the lock both would read the old file, and whichever renamed last would silently drop the other’s series while both reported success. An OS lock rather than an exclusively created marker file, because the OS releases it when a process dies; a marker left by a killed run would block every save after it until someone deleted it by hand.

Trait Implementations§

Source§

impl Clone for Store

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 Store

Source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl Freeze for Store

§

impl RefUnwindSafe for Store

§

impl Send for Store

§

impl Sync for Store

§

impl Unpin for Store

§

impl UnsafeUnpin for Store

§

impl UnwindSafe for Store

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.