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

Bring dev-dependencies up-to-date. #491

Merged
merged 9 commits into from Jul 26, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
14 changes: 14 additions & 0 deletions .github/workflows/audit.yml
@@ -0,0 +1,14 @@
name: Security audit
on:
push:
paths:
- '**/Cargo.toml'
- '**/Cargo.lock'
jobs:
security_audit:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- uses: actions-rs/audit-check@v1
with:
token: ${{ secrets.GITHUB_TOKEN }}
4 changes: 3 additions & 1 deletion .github/workflows/ci.yaml
Expand Up @@ -17,7 +17,7 @@ jobs:
- stable
- beta
- nightly
- 1.40.0 # MSRV
- 1.46.0 # MSRV

steps:
- uses: actions/checkout@v2
Expand All @@ -34,10 +34,12 @@ jobs:
- uses: actions-rs/cargo@v1
with:
command: build
args: --features stable

- uses: actions-rs/cargo@v1
with:
command: test
args: --features stable

- uses: actions-rs/cargo@v1
if: ${{ matrix.rust == 'stable' }}
Expand Down
90 changes: 47 additions & 43 deletions Cargo.toml
@@ -1,59 +1,63 @@
[package]
authors = ["Jorge Aparicio <japaricious@gmail.com>", "Brook Heisler <brookheisler@gmail.com>"]
name = "criterion"
authors = [
"Jorge Aparicio <japaricious@gmail.com>",
"Brook Heisler <brookheisler@gmail.com>",
]
name = "criterion"
version = "0.3.4"
edition = "2018"

description = "Statistics-driven micro-benchmarking library"
homepage = "https://bheisler.github.io/criterion.rs/book/index.html"
repository = "https://github.com/bheisler/criterion.rs"
readme = "README.md"
keywords = ["criterion", "benchmark"]
categories = ["development-tools::profiling"]
license = "Apache-2.0/MIT"
exclude = ["book/*"]
homepage = "https://bheisler.github.io/criterion.rs/book/index.html"
repository = "https://github.com/bheisler/criterion.rs"
readme = "README.md"
keywords = ["criterion", "benchmark"]
categories = ["development-tools::profiling"]
license = "Apache-2.0/MIT"
exclude = ["book/*"]

[dependencies]
lazy_static = "1.4"
criterion-plot = { path="plot", version="0.4.3" }
itertools = "0.10"
serde = "1.0"
serde_json = "1.0"
serde_derive = "1.0"
serde_cbor = "0.11"
atty = "0.2"
clap = { version = "2.33", default-features = false }
csv = "1.1"
walkdir = "2.3"
tinytemplate = "1.1"
cast = "0.2"
num-traits = { version = "0.2", default-features = false }
oorandom = "11.1"
rayon = "1.3"
regex = { version = "1.3", default-features = false, features = ["std"] }
futures = { version = "0.3", default_features = false, optional = true }
smol = { version = "1.2", default-features = false, optional = true }
tokio = { version = "1.0", default-features = false, features = ["rt"], optional = true }
async-std = { version = "1.9", optional = true }
lazy_static = "1.4"
criterion-plot = { path = "plot", version = "0.4.3" }
itertools = "0.10"
serde = "1.0"
serde_json = "1.0"
serde_derive = "1.0"
serde_cbor = "0.11"
atty = "0.2"
clap = { version = "2.33", default-features = false }
csv = "1.1"
walkdir = "2.3"
tinytemplate = "1.1"
cast = "0.2"
num-traits = { version = "0.2", default-features = false }
oorandom = "11.1"
rayon = "1.3"
regex = { version = "1.3", default-features = false, features = ["std"] }
futures = { version = "0.3", default_features = false, optional = true }
smol = { version = "1.2", default-features = false, optional = true }
tokio = { version = "1.0", default-features = false, features = ["rt"], optional = true }
async-std = { version = "1.9", optional = true }

[dependencies.plotters]
version = "^0.3.1"
version = "^0.3.1"
default-features = false
features = ["svg_backend", "area_series", "line_series"]
features = ["svg_backend", "area_series", "line_series"]

[dev-dependencies]
tempfile = "3.1"
approx = "0.4"
quickcheck = { version = "0.9", default-features = false }
rand = "0.8"
futures = { version = "0.3", default_features = false, features = ["executor"] }
tempfile = "3.2.0"
approx = "0.5.0"
quickcheck = { version = "1.0", default-features = false }
rand = "0.8"
futures = { version = "0.3", default_features = false, features = ["executor"] }

[badges]
travis-ci = { repository = "bheisler/criterion.rs" }
appveyor = { repository = "bheisler/criterion.rs", id = "4255ads9ctpupcl2" }
travis-ci = { repository = "bheisler/criterion.rs" }
appveyor = { repository = "bheisler/criterion.rs", id = "4255ads9ctpupcl2" }
maintenance = { status = "passively-maintained" }

[features]
stable = ["async_futures", "async_smol", "async_tokio", "async_std"]
default = ["cargo_bench_support"]

# Enable use of the nightly-only test::black_box function to discourage compiler optimizations.
Expand All @@ -65,9 +69,9 @@ async = ["futures"]
# These features enable built-in support for running async benchmarks on each different async
# runtime.
async_futures = ["futures/executor", "async"]
async_smol = ["smol", "async"]
async_tokio = ["tokio", "async"]
async_std = ["async-std", "async"]
async_smol = ["smol", "async"]
async_tokio = ["tokio", "async"]
async_std = ["async-std", "async"]

# This feature _currently_ does nothing except disable a warning message, but in 0.4.0 it will be
# required in order to have Criterion.rs generate its own plots (as opposed to using cargo-criterion)
Expand All @@ -86,7 +90,7 @@ csv_output = []
exclude = ["cargo-criterion"]

[[bench]]
name = "bench_main"
name = "bench_main"
harness = false

[lib]
Expand Down
2 changes: 1 addition & 1 deletion README.md
Expand Up @@ -119,7 +119,7 @@ For more details, see the [CONTRIBUTING.md file](https://github.com/bheisler/cri
Criterion.<span></span>rs supports the last three stable minor releases of Rust. At time of
writing, this means Rust 1.50 or later. Older versions may work, but are not guaranteed.

Currently, the oldest version of Rust believed to work is 1.40. Future versions of Criterion.<span></span>rs may
Currently, the oldest version of Rust believed to work is 1.46. Future versions of Criterion.<span></span>rs may
break support for such old versions, and this will not be considered a breaking change. If you
require Criterion.<span></span>rs to work on old versions of Rust, you will need to stick to a
specific patch version of Criterion.<span></span>rs.
Expand Down
6 changes: 3 additions & 3 deletions src/csv_report.rs
Expand Up @@ -31,14 +31,14 @@ impl<W: Write> CsvReportWriter<W> {
let mut data_scaled: Vec<f64> = data.sample_times().as_ref().into();
let unit = formatter.scale_for_machines(&mut data_scaled);
let group = id.group_id.as_str();
let function = id.function_id.as_ref().map(String::as_str);
let value = id.value_str.as_ref().map(String::as_str);
let function = id.function_id.as_deref();
let value = id.value_str.as_deref();
let (throughput_num, throughput_type) = match id.throughput {
Some(Throughput::Bytes(bytes)) => (Some(format!("{}", bytes)), Some("bytes")),
Some(Throughput::Elements(elems)) => (Some(format!("{}", elems)), Some("elements")),
None => (None, None),
};
let throughput_num = throughput_num.as_ref().map(String::as_str);
let throughput_num = throughput_num.as_deref();

for (count, measured_value) in data.iter_counts().iter().zip(data_scaled.into_iter()) {
let row = CsvRow {
Expand Down
18 changes: 7 additions & 11 deletions src/html/mod.rs
Expand Up @@ -199,8 +199,8 @@ impl<'a> BenchmarkGroup<'a> {
let mut individual_links = HashMap::with_capacity(ids.len());

for id in ids.iter() {
let function_id = id.function_id.as_ref().map(String::as_str);
let value = id.value_str.as_ref().map(String::as_str);
let function_id = id.function_id.as_deref();
let value = id.value_str.as_deref();

let individual_link = ReportLink::individual(output_directory, id);

Expand Down Expand Up @@ -497,17 +497,13 @@ impl Report for Html {
// First sort the ids/data by value.
// If all of the value strings can be parsed into a number, sort/dedupe
// numerically. Otherwise sort lexicographically.
let all_values_numeric = all_data.iter().all(|(id, _)| {
id.value_str
.as_ref()
.map(String::as_str)
.and_then(try_parse)
.is_some()
});
let all_values_numeric = all_data
.iter()
.all(|(id, _)| id.value_str.as_deref().and_then(try_parse).is_some());
if all_values_numeric {
all_data.sort_unstable_by(|(a, _), (b, _)| {
let num1 = a.value_str.as_ref().map(String::as_str).and_then(try_parse);
let num2 = b.value_str.as_ref().map(String::as_str).and_then(try_parse);
let num1 = a.value_str.as_deref().and_then(try_parse);
let num2 = b.value_str.as_deref().and_then(try_parse);

num1.partial_cmp(&num2).unwrap_or(Ordering::Less)
});
Expand Down
12 changes: 2 additions & 10 deletions src/lib.rs
Expand Up @@ -23,9 +23,7 @@
allow(
clippy::just_underscores_and_digits, // Used in the stats code
clippy::transmute_ptr_to_ptr, // Used in the stats code
clippy::option_as_ref_deref, // Remove when MSRV bumped above 1.40
clippy::manual_non_exhaustive, // Remove when MSRV bumped above 1.40
clippy::match_like_matches_macro, // Remove when MSRV bumped above 1.42
)
)]

Expand Down Expand Up @@ -339,10 +337,7 @@ pub(crate) enum Mode {
}
impl Mode {
pub fn is_benchmark(&self) -> bool {
match self {
Mode::Benchmark => true,
_ => false,
}
matches!(self, Mode::Benchmark)
}
}

Expand Down Expand Up @@ -1515,10 +1510,7 @@ impl ActualSamplingMode {
}

fn is_linear(&self) -> bool {
match self {
ActualSamplingMode::Linear => true,
_ => false,
}
matches!(self, ActualSamplingMode::Linear)
}

fn recommend_linear_sample_size(target_time: f64, met: f64) -> u64 {
Expand Down
16 changes: 12 additions & 4 deletions src/stats/bivariate/bootstrap.rs
Expand Up @@ -10,8 +10,12 @@ macro_rules! test {
use crate::stats::bivariate::Data;

quickcheck! {
fn means(size: usize, start: usize,
offset: usize, nresamples: usize) -> TestResult {
fn means(size: u8, start: u8,
offset: u8, nresamples: u8) -> TestResult {
let size = size as usize;
let start = start as usize;
let offset = offset as usize;
let nresamples = nresamples as usize;
if let Some(x) = crate::stats::test::vec::<$ty>(size, start) {
let y = crate::stats::test::vec::<$ty>(size + offset, start + offset).unwrap();
let data = Data::new(&x[start..], &y[start+offset..]);
Expand Down Expand Up @@ -48,8 +52,12 @@ macro_rules! test {
}

quickcheck! {
fn slope(size: usize, start: usize,
offset: usize, nresamples: usize) -> TestResult {
fn slope(size: u8, start: u8,
offset: u8, nresamples: u8) -> TestResult {
let size = size as usize;
let start = start as usize;
let offset = offset as usize;
let nresamples = nresamples as usize;
if let Some(x) = crate::stats::test::vec::<$ty>(size, start) {
let y = crate::stats::test::vec::<$ty>(size + offset, start + offset).unwrap();
let data = Data::new(&x[start..], &y[start+offset..]);
Expand Down
32 changes: 24 additions & 8 deletions src/stats/univariate/bootstrap.rs
Expand Up @@ -9,7 +9,10 @@ macro_rules! test {
use crate::stats::univariate::{Sample, mixed, self};

quickcheck!{
fn mean(size: usize, start: usize, nresamples: usize) -> TestResult {
fn mean(size: u8, start: u8, nresamples: u8) -> TestResult {
let size = size as usize;
let start = start as usize;
let nresamples = nresamples as usize;
if let Some(v) = crate::stats::test::vec::<$ty>(size, start) {
let sample = Sample::new(&v[start..]);

Expand Down Expand Up @@ -38,7 +41,10 @@ macro_rules! test {
}

quickcheck!{
fn mean_median(size: usize, start: usize, nresamples: usize) -> TestResult {
fn mean_median(size: u8, start: u8, nresamples: u8) -> TestResult {
let size = size as usize;
let start = start as usize;
let nresamples = nresamples as usize;
if let Some(v) = crate::stats::test::vec::<$ty>(size, start) {
let sample = Sample::new(&v[start..]);

Expand Down Expand Up @@ -73,10 +79,15 @@ macro_rules! test {

quickcheck!{
fn mixed_two_sample(
a_size: usize, a_start: usize,
b_size: usize, b_start: usize,
nresamples: usize
a_size: u8, a_start: u8,
b_size: u8, b_start: u8,
nresamples: u8
) -> TestResult {
let a_size = a_size as usize;
let b_size = b_size as usize;
let a_start = a_start as usize;
let b_start = b_start as usize;
let nresamples = nresamples as usize;
if let (Some(a), Some(b)) =
(crate::stats::test::vec::<$ty>(a_size, a_start), crate::stats::test::vec::<$ty>(b_size, b_start))
{
Expand Down Expand Up @@ -109,10 +120,15 @@ macro_rules! test {

quickcheck!{
fn two_sample(
a_size: usize, a_start: usize,
b_size: usize, b_start: usize,
nresamples: usize
a_size: u8, a_start: u8,
b_size: u8, b_start: u8,
nresamples: u8
) -> TestResult {
let a_size = a_size as usize;
let b_size = b_size as usize;
let a_start = a_start as usize;
let b_start = b_start as usize;
let nresamples = nresamples as usize;
if let (Some(a), Some(b)) =
(crate::stats::test::vec::<$ty>(a_size, a_start), crate::stats::test::vec::<$ty>(b_size, b_start))
{
Expand Down
4 changes: 3 additions & 1 deletion src/stats/univariate/kde/kernel.rs
Expand Up @@ -39,13 +39,15 @@ macro_rules! test {

quickcheck! {
fn symmetric(x: $ty) -> bool {
relative_eq!(Gaussian.evaluate(-x), Gaussian.evaluate(x))
x.is_nan() || relative_eq!(Gaussian.evaluate(-x), Gaussian.evaluate(x))
}
}

// Any [a b] integral should be in the range [0 1]
quickcheck! {
fn integral(a: $ty, b: $ty) -> TestResult {
let a = a.sin().abs(); // map the value to [0 1]
let b = b.sin().abs(); // map the value to [0 1]
const DX: $ty = 1e-3;

if a > b {
Expand Down
4 changes: 3 additions & 1 deletion src/stats/univariate/kde/mod.rs
Expand Up @@ -98,7 +98,9 @@ macro_rules! test {

// The [-inf inf] integral of the estimated PDF should be one
quickcheck! {
fn integral(size: usize, start: usize) -> TestResult {
fn integral(size: u8, start: u8) -> TestResult {
let size = size as usize;
let start = start as usize;
const DX: $ty = 1e-3;

if let Some(v) = crate::stats::test::vec::<$ty>(size, start) {
Expand Down