Skip to content

Commit a5780a6

Browse files
committed
Bump criterion to version 0.7
1 parent 12987a3 commit a5780a6

17 files changed

Lines changed: 61 additions & 52 deletions

File tree

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ sprs = { version = "0.11", default-features = false }
4646

4747
thiserror = "2.0"
4848

49-
criterion = { version = "0.5", optional = true }
49+
criterion = { version = "0.7", optional = true }
5050

5151
[dependencies.serde_crate]
5252
package = "serde"

algorithms/linfa-clustering/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ ndarray-npy = { version = "0.9", default-features = false }
5454
linfa-datasets = { version = "0.7.1", path = "../../datasets", features = [
5555
"generate",
5656
] }
57-
criterion = "0.5"
57+
criterion = "0.7"
5858
serde_json = "1"
5959
approx = "0.5"
6060
lax = "0.17.0"

algorithms/linfa-clustering/benches/dbscan.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
use criterion::{
2-
black_box, criterion_group, criterion_main, AxisScale, BenchmarkId, Criterion,
3-
PlotConfiguration,
2+
criterion_group, criterion_main, AxisScale, BenchmarkId, Criterion, PlotConfiguration,
43
};
54
use linfa::benchmarks::config;
65
use linfa::prelude::{ParamGuard, Transformer};
@@ -34,7 +33,7 @@ fn dbscan_bench(c: &mut Criterion) {
3433
let dataset = generate::blobs(cluster_size, &centroids, rng);
3534

3635
bencher.iter(|| {
37-
black_box(
36+
std::hint::black_box(
3837
Dbscan::params(min_points)
3938
.tolerance(tolerance)
4039
.check_unwrap()

algorithms/linfa-clustering/benches/gaussian_mixture.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
use criterion::{
2-
black_box, criterion_group, criterion_main, AxisScale, BenchmarkId, Criterion,
3-
PlotConfiguration,
2+
criterion_group, criterion_main, AxisScale, BenchmarkId, Criterion, PlotConfiguration,
43
};
54
use linfa::benchmarks::config;
65
use linfa::traits::Fit;
@@ -34,7 +33,7 @@ fn gaussian_mixture_bench(c: &mut Criterion) {
3433
let dataset: DatasetBase<_, _> =
3534
(generate::blobs(cluster_size, &centroids, rng)).into();
3635
bencher.iter(|| {
37-
black_box(
36+
std::hint::black_box(
3837
GaussianMixtureModel::params(n_clusters)
3938
.with_rng(rng.clone())
4039
.tolerance(1e-3)

algorithms/linfa-clustering/benches/k_means.rs

Lines changed: 26 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
use criterion::{
2-
black_box, criterion_group, criterion_main, AxisScale, BenchmarkId, Criterion,
2+
criterion_group, criterion_main, AxisScale, BenchmarkId, Criterion,
33
PlotConfiguration,
44
};
55
use linfa::benchmarks::config;
@@ -53,12 +53,15 @@ fn k_means_bench(c: &mut Criterion) {
5353
BenchmarkId::new("naive_k_means", format!("{n_clusters}x{cluster_size}")),
5454
|bencher| {
5555
bencher.iter(|| {
56-
let m = KMeans::params_with_rng(black_box(n_clusters), black_box(rng.clone()))
57-
.init_method(KMeansInit::KMeansPlusPlus)
58-
.max_n_iterations(black_box(1000))
59-
.tolerance(black_box(1e-3))
60-
.fit(&dataset)
61-
.unwrap();
56+
let m = KMeans::params_with_rng(
57+
std::hint::black_box(n_clusters),
58+
std::hint::black_box(rng.clone()),
59+
)
60+
.init_method(KMeansInit::KMeansPlusPlus)
61+
.max_n_iterations(std::hint::black_box(1000))
62+
.tolerance(std::hint::black_box(1e-3))
63+
.fit(&dataset)
64+
.unwrap();
6265
stats.add(m.inertia());
6366
});
6467
},
@@ -92,12 +95,14 @@ fn k_means_incr_bench(c: &mut Criterion) {
9295
),
9396
|bencher| {
9497
bencher.iter(|| {
95-
let clf =
96-
KMeans::params_with_rng(black_box(n_clusters), black_box(rng.clone()))
97-
.init_method(KMeansInit::KMeansPlusPlus)
98-
.tolerance(black_box(1e-3))
99-
.check()
100-
.unwrap();
98+
let clf = KMeans::params_with_rng(
99+
std::hint::black_box(n_clusters),
100+
std::hint::black_box(rng.clone()),
101+
)
102+
.init_method(KMeansInit::KMeansPlusPlus)
103+
.tolerance(std::hint::black_box(1e-3))
104+
.check()
105+
.unwrap();
101106
let model = dataset
102107
.sample_chunks(200)
103108
.cycle()
@@ -146,13 +151,14 @@ fn k_means_init_bench(c: &mut Criterion) {
146151
bencher.iter(|| {
147152
// Do 1 run of KMeans with 1 iterations, so it's mostly just the init
148153
// algorithm
149-
let m = KMeans::params_with_rng(black_box(n_clusters), rng.clone())
150-
.init_method(init.clone())
151-
.max_n_iterations(1)
152-
.n_runs(1)
153-
.tolerance(1000.0) // Guaranteed convergence
154-
.fit(&dataset)
155-
.unwrap();
154+
let m =
155+
KMeans::params_with_rng(std::hint::black_box(n_clusters), rng.clone())
156+
.init_method(init.clone())
157+
.max_n_iterations(1)
158+
.n_runs(1)
159+
.tolerance(1000.0) // Guaranteed convergence
160+
.fit(&dataset)
161+
.unwrap();
156162
stats.add(m.inertia());
157163
});
158164
},

algorithms/linfa-ftrl/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ rand_xoshiro = "0.6.0"
3535
linfa = { version = "0.7.1", path = "../.." }
3636

3737
[dev-dependencies]
38-
criterion = "0.5"
38+
criterion = "0.7"
3939
approx = "0.5"
4040
linfa-datasets = { version = "0.7.1", path = "../../datasets", features = [
4141
"winequality",

algorithms/linfa-ftrl/benches/ftrl.rs

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use criterion::{black_box, criterion_group, criterion_main, BenchmarkId, Criterion};
1+
use criterion::{criterion_group, criterion_main, BenchmarkId, Criterion};
22
use linfa::benchmarks::config;
33
use linfa::prelude::Predict;
44
use linfa::traits::FitWith;
@@ -24,7 +24,9 @@ fn fit_without_prior_model(c: &mut Criterion) {
2424
BenchmarkId::new("training on ", format!("dataset {nfeatures}x{nrows}")),
2525
|bencher| {
2626
bencher.iter(|| {
27-
params.fit_with(None, black_box(&dataset)).unwrap();
27+
params
28+
.fit_with(None, std::hint::black_box(&dataset))
29+
.unwrap();
2830
});
2931
},
3032
);
@@ -50,7 +52,10 @@ fn fit_with_prior_model(c: &mut Criterion) {
5052
|bencher| {
5153
bencher.iter(|| {
5254
let _ = params
53-
.fit_with(black_box(Some(model.clone())), black_box(&dataset))
55+
.fit_with(
56+
std::hint::black_box(Some(model.clone())),
57+
std::hint::black_box(&dataset),
58+
)
5459
.unwrap();
5560
});
5661
},
@@ -75,7 +80,7 @@ fn predict(c: &mut Criterion) {
7580
BenchmarkId::new("predicting on ", format!("dataset {nfeatures}x{nrows}")),
7681
|bencher| {
7782
bencher.iter(|| {
78-
model.predict(black_box(&dataset));
83+
model.predict(std::hint::black_box(&dataset));
7984
});
8085
},
8186
);

algorithms/linfa-ica/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ linfa = { version = "0.7.1", path = "../.." }
3939
[dev-dependencies]
4040
ndarray-npy = { version = "0.9", default-features = false }
4141
paste = "1.0"
42-
criterion = "0.5"
42+
criterion = "0.7"
4343
linfa = { version = "0.7.1", path = "../..", features = ["benchmarks"] }
4444

4545
[[bench]]

algorithms/linfa-linear/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ linfa-datasets = { version = "0.7.1", path = "../../datasets", features = [
4444
"diabetes",
4545
] }
4646
approx = "0.5"
47-
criterion = "0.5"
47+
criterion = "0.7"
4848
statrs = "0.18"
4949
linfa = { version = "0.7.1", path = "../..", features = ["benchmarks"] }
5050

algorithms/linfa-nn/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ linfa = { version = "0.7.1", path = "../.." }
3737

3838
[dev-dependencies]
3939
approx = "0.5"
40-
criterion = "0.5"
40+
criterion = "0.7"
4141
rand_xoshiro = "0.6"
4242
ndarray-rand = "0.15"
4343
linfa = { version = "0.7.1", path = "../..", features = ["benchmarks"] }

0 commit comments

Comments
 (0)