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
impl Report
Sourcepub fn builder() -> Builder
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());Sourcepub fn table<I>(headers: I) -> Table
pub fn table<I>(headers: I) -> Table
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);Sourcepub fn info<T>(info: T) -> Self
pub fn info<T>(info: T) -> Self
Report info for diagnostic purposes.
The information will be displayed and serialized unchanged.
Sourcepub fn error<T>(error: T) -> Selfwhere
T: ToString,
pub fn error<T>(error: T) -> Selfwhere
T: ToString,
Report an error.
Errors are considered a failure for diagnostic purposes.
The error will be displayed and serialized using its ToString representation.
Sourcepub fn equal<T>(old: T, new: T) -> Self
pub fn equal<T>(old: T, new: T) -> Self
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.
Sourcepub fn equal_with_tolerance<T, U>(
tolerance: &T,
old: U,
new: U,
spec: FmtSpec,
) -> Selfwhere
T: EqualWithTolerance<U>,
pub fn equal_with_tolerance<T, U>(
tolerance: &T,
old: U,
new: U,
spec: FmtSpec,
) -> Selfwhere
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);Sourcepub fn higher_is_better<T, U>(
tolerance: &T,
old: U,
new: U,
spec: FmtSpec,
) -> Selfwhere
T: HigherIsBetter<U>,
pub fn higher_is_better<T, U>(
tolerance: &T,
old: U,
new: U,
spec: FmtSpec,
) -> Selfwhere
T: HigherIsBetter<U>,
Construct a new Report using tolerance::HigherIsBetter.
Sourcepub fn lower_is_better<T, U>(
tolerance: &T,
old: U,
new: U,
spec: FmtSpec,
) -> Selfwhere
T: LowerIsBetter<U>,
pub fn lower_is_better<T, U>(
tolerance: &T,
old: U,
new: U,
spec: FmtSpec,
) -> Selfwhere
T: LowerIsBetter<U>,
Construct a new Report using tolerance::LowerIsBetter.