Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
34815ac
add a bunch of assertions that measurements are not zero, trying to t…
May 25, 2025
a867eeb
fix "zero-time measurements" bug
May 25, 2025
16926d8
add a couple of more asserts that measurements aren't 0 (or epsilon)
May 25, 2025
ae543cd
add another fix for measurements being 0 in a different place
May 25, 2025
1a0113e
add docstring
May 25, 2025
56edb08
interim commit (doesn't compile!)
May 27, 2025
8cef4c2
use the new "{varname}" format instead of "{}, varname" to make clippy
May 27, 2025
7fc5cce
Cargo.lock
May 28, 2025
fd8f7b0
inline a bunch more formatted variables
May 28, 2025
8c02527
bring the RDPTSCP measurement over from smalloc
May 28, 2025
cecd263
remove debug printout
May 28, 2025
a7e7359
fix MachAbsoluteTimer
May 28, 2025
a3065a3
fix clippies
May 28, 2025
f305d2e
bug fix: if mach_absolute_time returns the same number as the previou…
Jun 19, 2025
95d2353
add dep on rayon
Jun 19, 2025
64ec260
if estimate would return NaN due to dividing by 0, then instead divid…
Jun 19, 2025
a7d6fe5
make a unit test go from red to green, by checking if the measured ti…
Jun 19, 2025
94f4a92
follow-on to the previous patch. This adds the same behavior to every…
Jun 19, 2025
bca5938
make WallTime Measurement return 1 nanosecond if its elapsed time is …
Jun 21, 2025
02c0d07
make RDTSCP satisfy the "measurements must be greater than 0" require…
Jun 21, 2025
1aaee9f
add debug_asserts that the Measurement object satisfies the new contr…
Jun 21, 2025
01b895f
Do the same hack with elapsed_time that the recent patches do to Meas…
Jun 21, 2025
8321601
add assertions that there are not NaN's or Infinites in various float…
Jun 22, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@ categories = ["development-tools::profiling"]
license = "Apache-2.0 OR MIT"
exclude = ["book/*"]

[lints.clippy]
uninlined_format_args = "allow"

[dependencies]
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perhaps move the format_arg changes to a separate PR?

anes = "0.1.4"
criterion-plot = { path = "plot", version = "0.5.0" }
Expand Down
2 changes: 1 addition & 1 deletion src/analysis/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ pub(crate) fn common<M: Measurement, T: ?Sized>(
match loaded {
Err(err) => panic!(
"Baseline '{base}' must exist before it can be loaded; try --save-baseline {base}. Error: {err}",
base = baseline, err = err
base=criterion.baseline_directory,
),
Ok(samples) => {
sampling_mode = samples.sampling_mode;
Expand Down
10 changes: 5 additions & 5 deletions src/benchmark_group.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ use std::time::Duration;
/// for x in 0..3 {
/// for y in 0..3 {
/// let point = (x, y);
/// let parameter_string = format!("{} * {}", x, y);
/// let parameter_string = format!("{x} * {y}");
/// group.bench_with_input(BenchmarkId::new("Multiply", parameter_string), &point,
/// |b, (p_x, p_y)| b.iter(|| p_x * p_y));
/// }
Expand Down Expand Up @@ -329,7 +329,7 @@ impl<'a, M: Measurement> BenchmarkGroup<'a, M> {
}
Mode::List(_) => {
if do_run {
println!("{}: benchmark", id);
println!("{id}: benchmark");
}
}
Mode::Test => {
Expand Down Expand Up @@ -440,7 +440,7 @@ impl BenchmarkId {
) -> BenchmarkId {
BenchmarkId {
function_name: Some(function_name.into()),
parameter: Some(format!("{}", parameter)),
parameter: Some(format!("{parameter}")),
}
}

Expand All @@ -449,7 +449,7 @@ impl BenchmarkId {
pub fn from_parameter<P: ::std::fmt::Display>(parameter: P) -> BenchmarkId {
BenchmarkId {
function_name: None,
parameter: Some(format!("{}", parameter)),
parameter: Some(format!("{parameter}")),
}
}

Expand All @@ -463,7 +463,7 @@ impl BenchmarkId {
pub(crate) fn no_function_with_input<P: ::std::fmt::Display>(parameter: P) -> BenchmarkId {
BenchmarkId {
function_name: None,
parameter: Some(format!("{}", parameter)),
parameter: Some(format!("{parameter}")),
}
}
}
Expand Down
9 changes: 3 additions & 6 deletions src/connection.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,18 +33,15 @@ impl std::fmt::Display for MessageError {
match self {
MessageError::Deserialization(error) => write!(
f,
"Failed to deserialize message to Criterion.rs benchmark:\n{}",
error
"Failed to deserialize message to Criterion.rs benchmark:\n{error}"
),
MessageError::Serialization(error) => write!(
f,
"Failed to serialize message to Criterion.rs benchmark:\n{}",
error
"Failed to serialize message to Criterion.rs benchmark:\n{error}"
),
MessageError::Io(error) => write!(
f,
"Failed to read or write message to Criterion.rs benchmark:\n{}",
error
"Failed to read or write message to Criterion.rs benchmark:\n{error}"
),
}
}
Expand Down
9 changes: 4 additions & 5 deletions src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,18 +30,17 @@ impl fmt::Display for Error {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
match self {
Error::AccessError { path, inner } => {
write!(f, "Failed to access file {:?}: {}", path, inner)
write!(f, "Failed to access file {path:?}: {inner}")
}
Error::CopyError { from, to, inner } => {
write!(f, "Failed to copy file {:?} to {:?}: {}", from, to, inner)
write!(f, "Failed to copy file {from:?} to {to:?}: {inner}")
}
Error::SerdeError { path, inner } => write!(
f,
"Failed to read or write file {:?} due to serialization error: {}",
path, inner
"Failed to read or write file {path:?} due to serialization error: {inner}"
),
#[cfg(feature = "csv_output")]
Error::CsvError(inner) => write!(f, "CSV error: {}", inner),
Error::CsvError(inner) => write!(f, "CSV error: {inner}"),
}
}
}
Expand Down
22 changes: 11 additions & 11 deletions src/format.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,15 @@ pub fn time(ns: f64) -> String {

pub fn short(n: f64) -> String {
if n < 10.0 {
format!("{:.4}", n)
format!("{n:.4}")
} else if n < 100.0 {
format!("{:.3}", n)
format!("{n:.3}")
} else if n < 1000.0 {
format!("{:.2}", n)
format!("{n:.2}")
} else if n < 10000.0 {
format!("{:.1}", n)
format!("{n:.1}")
} else {
format!("{:.0}", n)
format!("{n:.0}")
}
}

Expand All @@ -39,21 +39,21 @@ fn signed_short(n: f64) -> String {

let sign = if n >= 0.0 { '+' } else { '\u{2212}' };
if n_abs < 10.0 {
format!("{}{:.4}", sign, n_abs)
format!("{sign}{n_abs:.4}")
} else if n_abs < 100.0 {
format!("{}{:.3}", sign, n_abs)
format!("{sign}{n_abs:.3}")
} else if n_abs < 1000.0 {
format!("{}{:.2}", sign, n_abs)
format!("{sign}{n_abs:.2}")
} else if n_abs < 10000.0 {
format!("{}{:.1}", sign, n_abs)
format!("{sign}{n_abs:.1}")
} else {
format!("{}{:.0}", sign, n_abs)
format!("{sign}{n_abs:.0}")
}
}

pub fn iter_count(iterations: u64) -> String {
if iterations < 10_000 {
format!("{} iterations", iterations)
format!("{iterations} iterations")
} else if iterations < 1_000_000 {
format!("{:.0}k iterations", (iterations as f64) / 1000.0)
} else if iterations < 10_000_000 {
Expand Down
6 changes: 3 additions & 3 deletions src/html/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,10 @@ fn debug_context<S: Serialize>(path: &Path, context: &S) {
if crate::debug_enabled() {
let mut context_path = PathBuf::from(path);
context_path.set_extension("json");
println!("Writing report context to {:?}", context_path);
println!("Writing report context to {context_path:?}");
let result = fs::save(context, &context_path);
if let Err(e) = result {
error!("Failed to write report context debug output: {}", e);
error!("Failed to write report context debug output: {e}");
}
}
}
Expand Down Expand Up @@ -69,7 +69,7 @@ impl IndividualBenchmark {

IndividualBenchmark {
name: id.as_title().to_owned(),
path: format!("{}/{}", path_prefix, id.as_directory_name()),
path: format!("{path_prefix}/{}", id.as_directory_name()),
regression_exists: regression_path.is_file(),
}
}
Expand Down
6 changes: 3 additions & 3 deletions src/plot/gnuplot_backend/distributions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ fn abs_distribution(
statistic
)))
.configure(Axis::BottomX, |a| {
a.set(Label(format!("Average time ({})", unit)))
a.set(Label(format!("Average time ({unit})")))
.set(Range::Limits(kde_xs_sample.min(), kde_xs_sample.max()))
})
.configure(Axis::LeftY, |a| a.set(Label("Density (a.u.)")))
Expand Down Expand Up @@ -113,7 +113,7 @@ fn abs_distribution(
},
);

let path = context.report_path(id, &format!("{}.svg", statistic));
let path = context.report_path(id, &format!("{statistic}.svg"));
debug_script(&path, &figure);
figure.set(Output(path)).draw().unwrap()
}
Expand Down Expand Up @@ -276,7 +276,7 @@ fn rel_distribution(
},
);

let path = context.report_path(id, &format!("change/{}.svg", statistic));
let path = context.report_path(id, &format!("change/{statistic}.svg"));
debug_script(&path, &figure);
figure.set(Output(path)).draw().unwrap()
}
Expand Down
4 changes: 2 additions & 2 deletions src/plot/gnuplot_backend/iteration_times.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ fn iteration_times_figure(
})
.configure(Axis::LeftY, |a| {
a.configure(Grid::Major, |g| g.show())
.set(Label(format!("Average Iteration Time ({})", unit)))
.set(Label(format!("Average Iteration Time ({unit})")))
})
.plot(
Points {
Expand Down Expand Up @@ -102,7 +102,7 @@ fn iteration_times_comparison_figure(
})
.configure(Axis::LeftY, |a| {
a.configure(Grid::Major, |g| g.show())
.set(Label(format!("Average Iteration Time ({})", unit)))
.set(Label(format!("Average Iteration Time ({unit})")))
})
.configure(Key, |k| {
k.set(Justification::Left)
Expand Down
8 changes: 4 additions & 4 deletions src/plot/gnuplot_backend/pdf.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ pub(crate) fn pdf(
let y_label = if exponent == 0 {
"Iterations".to_owned()
} else {
format!("Iterations (x 10^{})", exponent)
format!("Iterations (x 10^{exponent})")
};

let (xs, ys) = kde::sweep(scaled_avg_times, KDE_POINTS, None);
Expand All @@ -46,7 +46,7 @@ pub(crate) fn pdf(
.set(size.unwrap_or(SIZE))
.configure(Axis::BottomX, |a| {
let xs_ = Sample::new(&xs);
a.set(Label(format!("Average time ({})", unit)))
a.set(Label(format!("Average time ({unit})")))
.set(Range::Limits(xs_.min(), xs_.max()))
})
.configure(Axis::LeftY, |a| {
Expand Down Expand Up @@ -248,7 +248,7 @@ pub(crate) fn pdf_small(
.set(Font(DEFAULT_FONT))
.set(size.unwrap_or(SIZE))
.configure(Axis::BottomX, |a| {
a.set(Label(format!("Average time ({})", unit)))
a.set(Label(format!("Average time ({unit})")))
.set(Range::Limits(xs_.min(), xs_.max()))
})
.configure(Axis::LeftY, |a| {
Expand Down Expand Up @@ -317,7 +317,7 @@ fn pdf_comparison_figure(
.set(Font(DEFAULT_FONT))
.set(size.unwrap_or(SIZE))
.configure(Axis::BottomX, |a| {
a.set(Label(format!("Average time ({})", unit)))
a.set(Label(format!("Average time ({unit})")))
})
.configure(Axis::LeftY, |a| a.set(Label("Density (a.u.)")))
.configure(Axis::RightY, |a| a.hide())
Expand Down