Struct iai_callgrind::Fixtures

source ·
pub struct Fixtures(/* private fields */);
Expand description

A builder of Fixtures to specify the fixtures directory which will be copied into the sandbox

Examples

use iai_callgrind::Fixtures;
let fixtures: Fixtures = Fixtures::new("benches/fixtures");

Implementations§

source§

impl Fixtures

source

pub fn new<T>(path: T) -> Self
where T: Into<PathBuf>,

Create a new Fixtures struct

The fixtures argument specifies a path to a directory containing fixtures which you want to be available for all benchmarks and the before, after, setup and teardown functions. Per default, the fixtures directory will be copied as is into the sandbox directory of the benchmark including symlinks. See Fixtures::follow_symlinks to change that behavior.

Relative paths are interpreted relative to the benchmarked package. In a multi-package workspace this’ll be the package name of the benchmark. Otherwise, it’ll be the workspace root.

Examples

Here, the directory benches/my_fixtures (with a file test_1.txt in it) in the root of the package under test will be copied into the temporary workspace (for example /tmp/.tmp12345678). So,the benchmarks can access a fixture test_1.txt with a relative path like my_fixtures/test_1.txt

use iai_callgrind::Fixtures;

let fixtures: Fixtures = Fixtures::new("benches/my_fixtures");

If set to true, resolve symlinks in the Fixtures source directory

If set to true and the Fixtures directory contains symlinks, these symlinks are resolved and instead of the symlink the target file or directory will be copied into the fixtures directory.

Examples

Here, the directory benches/my_fixtures (with a symlink test_1.txt -> ../../test_1.txt in it) in the root of the package under test will be copied into the sandbox directory (for example /tmp/.tmp12345678). Since follow_symlink is true, the benchmarks can access a fixture test_1.txt with a relative path like my_fixtures/test_1.txt

use iai_callgrind::Fixtures;

let fixtures: &mut Fixtures = Fixtures::new("benches/my_fixtures").follow_symlinks(true);

Trait Implementations§

source§

impl AsRef<Fixtures> for Fixtures

source§

fn as_ref(&self) -> &Fixtures

Converts this type into a shared reference of the (usually inferred) input type.
source§

impl Clone for Fixtures

source§

fn clone(&self) -> Fixtures

Returns a copy 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 Fixtures

source§

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

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

impl From<&Fixtures> for InternalFixtures

source§

fn from(value: &Fixtures) -> Self

Converts to this type from the input type.
source§

impl From<&mut Fixtures> for InternalFixtures

source§

fn from(value: &mut Fixtures) -> Self

Converts to this type from the input type.
source§

impl From<Fixtures> for InternalFixtures

source§

fn from(value: Fixtures) -> Self

Converts to this type from the input type.

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

§

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>,

§

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>,

§

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.