diff options
author | Jeff Vander Stoep <jeffv@google.com> | 2023-03-10 20:32:17 +0000 |
---|---|---|
committer | Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com> | 2023-03-10 20:32:17 +0000 |
commit | c7a291994efff0716ff725cb4ab0bf56f38ea0e0 (patch) | |
tree | 233a7ce1b06fc9c6a665f69f59d627b1111a8cf9 /src/stats/bivariate/mod.rs | |
parent | 84147751e0fdbd38c3def24d5ad557400ef35b7e (diff) | |
parent | 19ca233fef56526b0864105a9061466883eca900 (diff) | |
download | criterion-c7a291994efff0716ff725cb4ab0bf56f38ea0e0.tar.gz |
Upgrade criterion to 0.4.0 am: 3c611a33f1 am: 8f1301829e am: 40e0d40821 am: 19ca233fef
Original change: https://android-review.googlesource.com/c/platform/external/rust/crates/criterion/+/2438096
Change-Id: Ic4a7be53328a27ef5efbe5b108ad3d53bb566024
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
Diffstat (limited to 'src/stats/bivariate/mod.rs')
-rwxr-xr-x | src/stats/bivariate/mod.rs | 53 |
1 files changed, 34 insertions, 19 deletions
diff --git a/src/stats/bivariate/mod.rs b/src/stats/bivariate/mod.rs index d1e8df7..2351c9e 100755 --- a/src/stats/bivariate/mod.rs +++ b/src/stats/bivariate/mod.rs @@ -8,6 +8,7 @@ use crate::stats::bivariate::resamples::Resamples; use crate::stats::float::Float; use crate::stats::tuple::{Tuple, TupledDistributionsBuilder}; use crate::stats::univariate::Sample; +#[cfg(feature = "rayon")] use rayon::iter::{IntoParallelIterator, ParallelIterator}; /// Bivariate `(X, Y)` data @@ -72,27 +73,41 @@ where T::Distributions: Send, T::Builder: Send, { - (0..nresamples) - .into_par_iter() - .map_init( - || Resamples::new(*self), - |resamples, _| statistic(resamples.next()), - ) - .fold( - || T::Builder::new(0), - |mut sub_distributions, sample| { + #[cfg(feature = "rayon")] + { + (0..nresamples) + .into_par_iter() + .map_init( + || Resamples::new(*self), + |resamples, _| statistic(resamples.next()), + ) + .fold( + || T::Builder::new(0), + |mut sub_distributions, sample| { + sub_distributions.push(sample); + sub_distributions + }, + ) + .reduce( + || T::Builder::new(0), + |mut a, mut b| { + a.extend(&mut b); + a + }, + ) + .complete() + } + #[cfg(not(feature = "rayon"))] + { + let mut resamples = Resamples::new(*self); + (0..nresamples) + .map(|_| statistic(resamples.next())) + .fold(T::Builder::new(0), |mut sub_distributions, sample| { sub_distributions.push(sample); sub_distributions - }, - ) - .reduce( - || T::Builder::new(0), - |mut a, mut b| { - a.extend(&mut b); - a - }, - ) - .complete() + }) + .complete() + } } /// Returns a view into the `X` data |