Skip to main content

Report

Struct Report 

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

A Check, Table, or nested grouping of multiple Reports used to gather regression checks across arbitrary benchamrks and reporting the overall success or failure.

On success, all attributes are printed.

use diskann_benchmark_runner::report::{Report, Check};

let mut builder = Report::builder();
{
    let mut nested = Report::builder();
    nested.push("foo", Report::equal(1, 1));
    nested.push("bar", Report::info("cat"));
    builder.push("nested", nested.finish());
}

let expected = "
nested:
  foo: 1
  bar: cat
".trim();

let report = builder.finish();
assert_eq!(report.to_string(), expected);

On failure, only the failing subset will be displayed.

Implementations§

Source§

impl Report

Source

pub fn builder() -> Builder

Construct an empty Builder for constructing hierarchical reports.

use diskann_benchmark_runner::report::Report;

let mut builder = Report::builder();
builder.push("foo", Report::info(10));
builder.push("baz", Report::equal(10, 10));
builder.push("bar", Report::equal(10, 20));
let report = builder.finish();

let s = report.to_string();
let expected = "
foo: 10
baz: 10
bar: (old) 10 != (new) 20 | FAIL
".trim();
assert_eq!(s, expected);
assert!(report.status().is_fail());
Source

pub fn table<I>(headers: I) -> Table
where I: IntoIterator<Item: Into<Cow<'static, str>>>,

Construct a Table using the provided list of headers.

use diskann_benchmark_runner::report::{Report, Check};

// Convenience for testing two renders.
fn process(x: &str) -> &str {
    let x = x.strip_prefix('\n').unwrap_or(x);
    x.strip_suffix('\n').unwrap_or(x)
}

let mut table = Report::table(["hello", "world"]);

// Tables are built one row at a time.
//
// Rows must be `finish`ed to be committed. Otherwise,
// their contents are // dropped.
let mut row = table.new_row();
row.push(Check::equal(10, 20)); // Failing check.
row.push(Check::info("bar"));
table.push_row(row).unwrap();
let report = table.finish();

let s = report.to_string();
let expected = process("
                 hello,   world,   status
=========================================
(old) 10 != (new) 20 !,     bar,     FAIL
");
assert_eq!(process(&s), expected);
Source

pub fn info<T>(info: T) -> Self
where T: Display + Serialize + 'static,

Report info for diagnostic purposes.

The information will be displayed and serialized unchanged.

Source

pub fn error<T>(error: T) -> Self
where T: ToString,

Report an error.

Errors are considered a failure for diagnostic purposes.

The error will be displayed and serialized using its ToString representation.

Source

pub fn equal<T>(old: T, new: T) -> Self
where T: Display + Serialize + PartialEq + 'static,

Assert that old == new.

If the check succeeds, one argument will be retained and displayed for informational purposes.

If the check fails, both values will be retained and the report fails.

Source

pub fn equal_with_tolerance<T, U>( tolerance: &T, old: U, new: U, spec: FmtSpec, ) -> Self
where T: EqualWithTolerance<U>,

Construct a new Report using tolerance::EqualWithTolerance.

use diskann_benchmark_runner::report::{
    Report, Status,
    tolerance::{FmtSpec, MaxAbsoluteChange},
};

let tolerance = MaxAbsoluteChange::from_u64(2);
let report = Report::equal_with_tolerance(&tolerance, 100u64, 102, FmtSpec::new());
assert_eq!(report.status(), Status::Pass);
Source

pub fn higher_is_better<T, U>( tolerance: &T, old: U, new: U, spec: FmtSpec, ) -> Self
where T: HigherIsBetter<U>,

Construct a new Report using tolerance::HigherIsBetter.

Source

pub fn lower_is_better<T, U>( tolerance: &T, old: U, new: U, spec: FmtSpec, ) -> Self
where T: LowerIsBetter<U>,

Construct a new Report using tolerance::LowerIsBetter.

Source

pub fn status(&self) -> Status

Return the Status of this report.

Status::Pass will only be reported if all nested Reports, Checks, and Tables report a pass.

Source

pub fn pass_fail(self) -> PassFail<Finished, Finished>

Convert self into a Finished.

Is this benchmark is a fail, then constructed Finished will only render the paths that failed. Otherwise, all paths will be rendered.

Trait Implementations§

Source§

impl Debug for Report

Source§

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

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

impl Display for Report

Source§

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

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

impl From<Check> for Report

Source§

fn from(check: Check) -> Self

Converts to this type from the input type.
Source§

impl From<Table> for Report

Source§

fn from(table: Table) -> Self

Converts to this type from the input type.
Source§

impl Serialize for Report

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more

Auto Trait Implementations§

§

impl !RefUnwindSafe for Report

§

impl !Send for Report

§

impl !Sync for Report

§

impl !UnwindSafe for Report

§

impl Forget for Report

§

impl Freeze for Report

§

impl Move for Report

§

impl Unpin for Report

§

impl UnsafeUnpin for Report

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<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

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.

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> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> Serialize for T
where T: Serialize + ?Sized,

Source§

fn erased_serialize(&self, serializer: &mut dyn Serializer) -> Result<(), Error>

Source§

fn do_erased_serialize( &self, serializer: &mut dyn Serializer, ) -> Result<(), ErrorImpl>

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 = !

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.