Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

use meaurement_time instead of target_time in the warning message #806

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
12 changes: 12 additions & 0 deletions book/src/user_guide/advanced_configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,18 @@ criterion_group!{
criterion_main!(benches);
```

It is also possible to change the Criterion.rs' default measurement time for benchmarks (defaults to 5.0s).

```rust
fn bench(c: &mut Criterion) {
let mut group = c.benchmark_group("measurement-time-example");
group.measurement_time(Duration::from_secs(30));
group.bench_function("my-function", |b| b.iter(|| my_function()));
group.finish();
}

```

## Throughput Measurements

When benchmarking some types of code it is useful to measure the throughput as well as the iteration time, either in bytes per second or elements per second. Criterion.rs can estimate the throughput of a benchmark, but it needs to know how many bytes or elements each iteration will process.
Expand Down
4 changes: 2 additions & 2 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1399,7 +1399,7 @@ impl ActualSamplingMode {
let recommended_sample_size =
ActualSamplingMode::recommend_linear_sample_size(m_ns as f64, met);
let actual_time = Duration::from_nanos(expected_ns as u64);
eprint!("\nWarning: Unable to complete {} samples in {:.1?}. You may wish to increase target time to {:.1?}",
eprint!("\nWarning: Unable to complete {} samples in {:.1?}. You may wish to increase measurement time to {:.1?}",
n, target_time, actual_time);

if recommended_sample_size != n {
Expand Down Expand Up @@ -1428,7 +1428,7 @@ impl ActualSamplingMode {
let recommended_sample_size =
ActualSamplingMode::recommend_flat_sample_size(m_ns, met);
let actual_time = Duration::from_nanos(expected_ns as u64);
eprint!("\nWarning: Unable to complete {} samples in {:.1?}. You may wish to increase target time to {:.1?}",
eprint!("\nWarning: Unable to complete {} samples in {:.1?}. You may wish to increase measurement time to {:.1?}",
n, target_time, actual_time);

if recommended_sample_size != n {
Expand Down