Skip to main content

Runner

Struct Runner 

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

Times targets against one context.

Implementations§

Source§

impl Runner

Source

pub fn new(ctx: Arc<Context>, profile: Profile, repo_root: &Path) -> Self

A runner over a context; the HTTP socket and the MCP child are started on first use.

Source

pub fn with_executable(self, path: PathBuf) -> Self

Spawn this executable for the MCP transport instead of the running one.

Source

pub fn with_share(self, share: PathBuf) -> Self

The share directory the MCP child reads (MAJORDOMUS_SHARE); the parent’s.

Source

pub fn with_repo_args(self, args: RepoArgs) -> Self

How the live view reloads the repository: the arguments the process read it with, so that a reload discovers the same root, distribution and discovery mode.

use majordomus_cli::bench::{BenchmarkProjection, Profile, Runner};
use majordomus_cli::cli::RepoArgs;
use majordomus_cli::synthetic::SyntheticRepository;
let repo = SyntheticRepository::small().unwrap();
let ctx = repo.context().unwrap();
let projection = BenchmarkProjection::from_context(&ctx);
let live = projection
    .targets
    .iter()
    .find(|t| t.key == "system.http.live.index")
    .unwrap();
let tiny = Profile { name: "doc", warmup: 0, samples: 2, cold_spawns: 1, deferred: false };
let args = RepoArgs {
    repo: Some(repo.root().to_path_buf()),
    ..RepoArgs::default()
};
let mut runner = Runner::new(ctx, tiny, repo.root()).with_repo_args(args);
// the live socket is served over a view started from these arguments
assert_eq!(runner.run(live).unwrap()[0].stats.samples, 2);
runner.finish();
Source

pub fn with_child_args(self, args: Vec<String>) -> Self

Arguments the MCP child gets after mcp --standalone, so that it reads the repository the way the parent did (--discovery filesystem, --strict).

Source

pub fn run( &mut self, target: &BenchmarkTarget, ) -> Result<Vec<BenchmarkResult>, Error>

Time one target: one result per cache mode it has.

Source

pub fn finish(self)

Stop the socket and the child.

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
§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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.

§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
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.
§

impl<T> WithSubscriber for T

§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more