Skip to content

Commit

Permalink
Improve doc linking. (#796)
Browse files Browse the repository at this point in the history
  • Loading branch information
waywardmonkeys authored Jul 26, 2024
1 parent 1a18e88 commit 4f56bb7
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 20 deletions.
12 changes: 6 additions & 6 deletions src/bencher.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ use crate::async_executor::AsyncExecutor;
/// * If your routine requires no per-iteration setup and returns a value with an expensive `drop`
/// method, use `iter_with_large_drop`.
/// * If your routine requires some per-iteration setup that shouldn't be timed, use `iter_batched`
/// or `iter_batched_ref`. See [`BatchSize`](enum.BatchSize.html) for a discussion of batch sizes.
/// or `iter_batched_ref`. See [`BatchSize`] for a discussion of batch sizes.
/// If the setup value implements `Drop` and you don't want to include the `drop` time in the
/// measurement, use `iter_batched_ref`, otherwise use `iter_batched`. These methods are also
/// suitable for benchmarking routines which return a value with an expensive `drop` method,
Expand Down Expand Up @@ -189,7 +189,7 @@ impl<'a, M: Measurement> Bencher<'a, M> {
}

/// Times a `routine` that requires some input by generating a batch of input, then timing the
/// iteration of the benchmark over the input. See [`BatchSize`](enum.BatchSize.html) for
/// iteration of the benchmark over the input. See [`BatchSize`] for
/// details on choosing the batch size. Use this when the routine must consume its input.
///
/// For example, use this loop to benchmark sorting algorithms, because they require unsorted
Expand Down Expand Up @@ -278,7 +278,7 @@ impl<'a, M: Measurement> Bencher<'a, M> {
}

/// Times a `routine` that requires some input by generating a batch of input, then timing the
/// iteration of the benchmark over the input. See [`BatchSize`](enum.BatchSize.html) for
/// iteration of the benchmark over the input. See [`BatchSize`] for
/// details on choosing the batch size. Use this when the routine should accept the input by
/// mutable reference.
///
Expand Down Expand Up @@ -384,7 +384,7 @@ impl<'a, M: Measurement> Bencher<'a, M> {
}
}

/// Async/await variant of the Bencher struct.
/// Async/await variant of [`Bencher`].
#[cfg(feature = "async")]
pub struct AsyncBencher<'a, 'b, A: AsyncExecutor, M: Measurement = WallTime> {
b: &'b mut Bencher<'a, M>,
Expand Down Expand Up @@ -567,7 +567,7 @@ impl<'a, 'b, A: AsyncExecutor, M: Measurement> AsyncBencher<'a, 'b, A, M> {
}

/// Times a `routine` that requires some input by generating a batch of input, then timing the
/// iteration of the benchmark over the input. See [`BatchSize`](enum.BatchSize.html) for
/// iteration of the benchmark over the input. See [`BatchSize`] for
/// details on choosing the batch size. Use this when the routine must consume its input.
///
/// For example, use this loop to benchmark sorting algorithms, because they require unsorted
Expand Down Expand Up @@ -664,7 +664,7 @@ impl<'a, 'b, A: AsyncExecutor, M: Measurement> AsyncBencher<'a, 'b, A, M> {
}

/// Times a `routine` that requires some input by generating a batch of input, then timing the
/// iteration of the benchmark over the input. See [`BatchSize`](enum.BatchSize.html) for
/// iteration of the benchmark over the input. See [`BatchSize`] for
/// details on choosing the batch size. Use this when the routine should accept the input by
/// mutable reference.
///
Expand Down
16 changes: 10 additions & 6 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -267,12 +267,14 @@ pub enum Baseline {
}

/// Enum used to select the plotting backend.
///
/// See [`Criterion::plotting_backend`].
#[derive(Debug, Clone, Copy)]
pub enum PlottingBackend {
/// Plotting backend which uses the external `gnuplot` command to render plots. This is the
/// default if the `gnuplot` command is installed.
Gnuplot,
/// Plotting backend which uses the rust 'Plotters' library. This is the default if `gnuplot`
/// Plotting backend which uses the Rust 'Plotters' library. This is the default if `gnuplot`
/// is not installed.
Plotters,
/// Null plotting backend which outputs nothing,
Expand Down Expand Up @@ -455,7 +457,7 @@ impl Default for Criterion {

impl<M: Measurement> Criterion<M> {
/// Changes the measurement for the benchmarks run with this runner. See the
/// Measurement trait for more details
/// [`Measurement`] trait for more details
pub fn with_measurement<M2: Measurement>(self, m: M2) -> Criterion<M2> {
// Can't use struct update syntax here because they're technically different types.
Criterion {
Expand All @@ -477,7 +479,7 @@ impl<M: Measurement> Criterion<M> {

#[must_use]
/// Changes the internal profiler for benchmarks run with this runner. See
/// the Profiler trait for more details.
/// the [`Profiler`] trait for more details.
pub fn with_profiler<P: Profiler + 'static>(self, p: P) -> Criterion<M> {
Criterion {
profiler: Box::new(RefCell::new(p)),
Expand All @@ -486,10 +488,12 @@ impl<M: Measurement> Criterion<M> {
}

#[must_use]
/// Set the plotting backend. By default, Criterion will use gnuplot if available, or plotters
/// if not.
/// Set the [plotting backend]. By default, Criterion will use `gnuplot` if available,
/// or `plotters` if not.
///
/// Panics if `backend` is [`PlottingBackend::Gnuplot`] and `gnuplot` is not available.
///
/// Panics if `backend` is `PlottingBackend::Gnuplot` and gnuplot is not available.
/// [plotting backend]: PlottingBackend
pub fn plotting_backend(mut self, backend: PlottingBackend) -> Criterion<M> {
if let PlottingBackend::Gnuplot = backend {
assert!(
Expand Down
15 changes: 8 additions & 7 deletions src/macros.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,15 @@
//! Criterion.rs benchmarks with `cargo bench`.

/// Macro used to define a function group for the benchmark harness; see the
/// `criterion_main!` macro for more details.
/// [`criterion_main!`](crate::criterion_main) macro for more details.
///
/// This is used to define a function group; a collection of functions to call with a common
/// Criterion configuration. Accepts two forms which can be seen below.
///
/// Note that the group name given here is not important, it must simply
/// be unique. Note also that this macro is not related to the `Criterion::benchmark_group` function
/// or the `BenchmarkGroup` type.
/// Note that the group name given here is not important, it must simply be
/// unique. Note also that this macro is not related to the
/// [`Criterion::benchmark_group`](crate::Criterion::benchmark_group) function
/// or the [`BenchmarkGroup`](crate::BenchmarkGroup) type.
///
/// # Examples:
///
Expand All @@ -36,9 +37,9 @@
/// ```
///
/// In this form, all of the options are clearly spelled out. This expands to
/// a function named benches, which uses the given config expression to create
/// an instance of the Criterion struct. This is then passed by mutable
/// reference to the targets.
/// a function named `benches`, which uses the given config expression to create
/// an instance of the [`Criterion`](crate::Criterion) struct. This is then
/// passed by mutable reference to the targets.
///
/// Compact Form:
///
Expand Down
2 changes: 1 addition & 1 deletion src/profiler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ pub trait Profiler {

/// This function is called after Criterion.rs stops profiling a particular
/// benchmark. The benchmark ID and directory are the same as in the call
/// to `start`, provided for convenience.
/// to [`start_profiling`](Self::start_profiling), provided for convenience.
fn stop_profiling(&mut self, benchmark_id: &str, benchmark_dir: &Path);
}

Expand Down

0 comments on commit 4f56bb7

Please sign in to comment.