pub struct Store { /* private fields */ }Expand description
The directory baselines are kept in.
Implementations§
Source§impl Store
impl Store
Sourcepub fn locate() -> Result<Self>
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.
pub fn dir(&self) -> &Path
Sourcepub fn load(&self, name: &str) -> Result<Baseline>
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.
Sourcepub fn check_saveable(&self, name: &str) -> Result<()>
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.
Sourcepub fn save(&self, name: &str, records: &[Record]) -> Result<PathBuf>
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.