Struct ToolOutputPath

Source
pub struct ToolOutputPath {
    pub baseline_kind: BaselineKind,
    pub dir: PathBuf,
    pub kind: ToolOutputPathKind,
    pub modifiers: Vec<String>,
    pub name: String,
    pub tool: ValgrindTool,
}
Available on crate feature runner only.
Expand description

The tool specific output path(s)

Fields§

§baseline_kind: BaselineKind§dir: PathBuf

The final directory of all the output files

§kind: ToolOutputPathKind§modifiers: Vec<String>

The modifiers which are prepended to the extension

§name: String

The name of this output path

§tool: ValgrindTool

The tool

Implementations§

Source§

impl ToolOutputPath

Source

pub fn new( kind: ToolOutputPathKind, tool: ValgrindTool, baseline_kind: &BaselineKind, base_dir: &Path, module: &ModulePath, name: &str, ) -> Self

Create a new ToolOutputPath.

The base_dir is supposed to be the same as crate::runner::meta::Metadata::target_dir. The name is supposed to be the name of the benchmark function. If a benchmark id is present join both with a dot as separator to get the final name.

Source

pub fn with_init( kind: ToolOutputPathKind, tool: ValgrindTool, baseline_kind: &BaselineKind, base_dir: &Path, module: &str, name: &str, ) -> Result<Self>

Initialize and create the output directory and organize files

This method moves the old output to $TOOL_ID.*.out.old

Source

pub fn init(&self) -> Result<()>

Initialize the directory in which the files are stored

Source

pub fn clear(&self) -> Result<()>

Remove the files of this output path

Source

pub fn shift(&self) -> Result<()>

Remove the old or base files and rename the present files to “old” files

Source

pub fn exists(&self) -> bool

Return true if a real file of this output path exists

Source

pub fn is_multiple(&self) -> bool

Return true if there are multiple real files of this output path

Source

pub fn to_base_path(&self) -> Self

Convert this output path to a base output path

Source

pub fn to_tool_output(&self, tool: ValgrindTool) -> Self

Convert this tool output path to the output of another tool output path

A tool with no *.out file is log-file based. If the other tool is a out-file based tool the ToolOutputPathKind will be converted and vice-versa. The “old” (base) type (a tool output converted with ToolOutputPath::to_base_path) will be converted to a new ToolOutputPath.

Source

pub fn to_log_output(&self) -> Self

Convert this tool output to the according log output

All tools have a log output even the ones which are out-file based.

Source

pub fn to_xtree_output(&self) -> Option<Self>

If possible, convert this tool output to the according xtree output

Not all tools support xtree output files

Source

pub fn to_xleak_output(&self) -> Option<Self>

If possible, convert this tool output to the according xleak output

Not all tools support xleak output files

Source

pub fn log_path_of(&self, path: &Path) -> Option<PathBuf>

Return the path to the log file for the given path

path is supposed to be a path to a valid file in the directory of this ToolOutputPath.

Source

pub fn dump_log<W>(&self, log_level: Level, writer: &mut W) -> Result<()>
where W: Write,

If the log::Level matches dump the content of all output files into the writer

Source

pub fn extension(&self) -> String

This method can only be used to create the path passed to the tools

The modifiers are extrapolated by the tools and won’t match any real path name.

Source

pub fn with_modifiers<I, T>(&self, modifiers: T) -> Self
where I: Into<String>, T: IntoIterator<Item = I>,

Create new ToolOutputPath with modifiers

Source

pub fn to_path(&self) -> PathBuf

Return the unexpanded path usable as input for --callgrind-out-file, …

The path returned by this method does not necessarily have to exist and can include modifiers like %p. Use Self::real_paths to get the real and existing (possibly multiple) paths to the output files of the respective tool.

Source

pub fn walk_dir(&self) -> Result<impl Iterator<Item = DirEntry>>

Walk the benchmark directory (non-recursive)

Source

pub fn strip_prefix<'a>(&self, file_name: &'a str) -> Option<&'a str>

Strip the <tool>.<name> prefix from a file_name

Source

pub fn prefix(&self) -> String

Return the file name prefix as in <tool>.<name>

Source

pub fn real_paths(&self) -> Result<Vec<PathBuf>>

Return the real paths of a tool’s output files

A tool can have many output files so Self::to_path is not enough

Source

pub fn real_paths_with_modifier(&self) -> Result<Vec<(PathBuf, Option<String>)>>

Return the real paths with their respective modifiers if present

Source

pub fn sanitize_callgrind(&self) -> Result<()>

Sanitize callgrind output file names

This method will remove empty files which are occasionally produced by callgrind and only cause problems in the parser. The files are renamed from the callgrind file naming scheme to ours which is easier to handle.

The information about pids, parts and threads is obtained by parsing the header from the callgrind output files instead of relying on the sometimes flaky file names produced by callgrind. The header is around 10-20 lines, so this method should be still sufficiently fast. Additionally, callgrind might change the naming scheme of its files, so using the headers makes us more independent of a specific valgrind/callgrind version.

Source

pub fn sanitize_bbv(&self) -> Result<()>

Sanitize bbv file names

The original output files of bb have a .<number> suffix if there are multiple threads. We need the threads as t<number> in the modifier part of the final file names.

For example: (orig -> sanitized)

If there are multiple threads, the bb output file name doesn’t include the first thread:

exp-bbv.bench_thread_in_subprocess.548365.bb.out -> exp-bbv.bench_thread_in_subprocess.548365.t1.bb.out

exp-bbv.bench_thread_in_subprocess.548365.bb.out.2 -> exp-bbv.bench_thread_in_subprocess.548365.t2.bb.out

Source

pub fn sanitize_generic(&self) -> Result<()>

Sanitize file names of all tools if not sanitized by a more specific method

The pids are removed from the file name if there was only a single process (pid). Additionally, we check for empty files and remove them.

Source

pub fn sanitize(&self) -> Result<()>

Sanitize file names for a specific tool

Empty files are cleaned up. For more details on a specific tool see the respective sanitize_ method.

Trait Implementations§

Source§

impl Clone for ToolOutputPath

Source§

fn clone(&self) -> ToolOutputPath

Returns a duplicate of the value. Read more
1.0.0 · Source§

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

Performs copy-assignment from source. Read more
Source§

impl Debug for ToolOutputPath

Source§

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

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

impl Display for ToolOutputPath

Source§

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

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

impl PartialEq for ToolOutputPath

Source§

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

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

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

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl Eq for ToolOutputPath

Source§

impl StructuralPartialEq for ToolOutputPath

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

Source§

fn __clone_box(&self, _: Private) -> *mut ()

Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. 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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

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

Source§

type EqTo = T

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> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
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.