Read-only mirrors. Development, issues and pull requests are on GitHub.

summaryrefslogtreecommitdiffhomepage
path: root/src/catch2/benchmark
diff options
context:
space:
mode:
authorMartin Hořeňovský2021-11-20 23:40:32 +0100
committerMartin Hořeňovský2021-11-23 23:16:08 +0100
commit8cb8f0b08b0ec35edd346df999f3b854ad05aa41 (patch)
treef3482554c1eea8b3389d933a31137e41203b795a /src/catch2/benchmark
parent9952f29f01ae1ab48b8c766ca70336bc3335f6e8 (diff)
downloadcatch3-8cb8f0b08b0ec35edd346df999f3b854ad05aa41.tar.gz
Sweep out some Wsign-conversion warnings
Diffstat (limited to 'src/catch2/benchmark')
-rw-r--r--src/catch2/benchmark/detail/catch_analyse.hpp4
-rw-r--r--src/catch2/benchmark/detail/catch_estimate_clock.hpp6
-rw-r--r--src/catch2/benchmark/detail/catch_stats.cpp8
-rw-r--r--src/catch2/benchmark/detail/catch_stats.hpp8
4 files changed, 13 insertions, 13 deletions
diff --git a/src/catch2/benchmark/detail/catch_analyse.hpp b/src/catch2/benchmark/detail/catch_analyse.hpp
index cf96a3d2..6652f5f4 100644
--- a/src/catch2/benchmark/detail/catch_analyse.hpp
+++ b/src/catch2/benchmark/detail/catch_analyse.hpp
@@ -28,7 +28,7 @@ namespace Catch {
SampleAnalysis<Duration> analyse(const IConfig &cfg, Environment<Duration>, Iterator first, Iterator last) {
if (!cfg.benchmarkNoAnalysis()) {
std::vector<double> samples;
- samples.reserve(last - first);
+ samples.reserve(static_cast<size_t>(last - first));
std::transform(first, last, std::back_inserter(samples), [](Duration d) { return d.count(); });
auto analysis = Catch::Benchmark::Detail::analyse_samples(cfg.benchmarkConfidenceInterval(), cfg.benchmarkResamples(), samples.begin(), samples.end());
@@ -54,7 +54,7 @@ namespace Catch {
};
} else {
std::vector<Duration> samples;
- samples.reserve(last - first);
+ samples.reserve(static_cast<size_t>(last - first));
Duration mean = Duration(0);
int i = 0;
diff --git a/src/catch2/benchmark/detail/catch_estimate_clock.hpp b/src/catch2/benchmark/detail/catch_estimate_clock.hpp
index 3bba791e..c392ca4f 100644
--- a/src/catch2/benchmark/detail/catch_estimate_clock.hpp
+++ b/src/catch2/benchmark/detail/catch_estimate_clock.hpp
@@ -29,11 +29,11 @@ namespace Catch {
template <typename Clock>
std::vector<double> resolution(int k) {
std::vector<TimePoint<Clock>> times;
- times.reserve(k + 1);
+ times.reserve(static_cast<size_t>(k + 1));
std::generate_n(std::back_inserter(times), k + 1, now<Clock>{});
std::vector<double> deltas;
- deltas.reserve(k);
+ deltas.reserve(static_cast<size_t>(k));
std::transform(std::next(times.begin()), times.end(), times.begin(),
std::back_inserter(deltas),
[](TimePoint<Clock> a, TimePoint<Clock> b) { return static_cast<double>((a - b).count()); });
@@ -83,7 +83,7 @@ namespace Catch {
auto&& r = run_for_at_least<Clock>(std::chrono::duration_cast<ClockDuration<Clock>>(clock_cost_estimation_time), iters, time_clock);
std::vector<double> times;
int nsamples = static_cast<int>(std::ceil(time_limit / r.elapsed));
- times.reserve(nsamples);
+ times.reserve(static_cast<size_t>(nsamples));
std::generate_n(std::back_inserter(times), nsamples, [time_clock, &r] {
return static_cast<double>((time_clock(r.iterations) / r.iterations).count());
});
diff --git a/src/catch2/benchmark/detail/catch_stats.cpp b/src/catch2/benchmark/detail/catch_stats.cpp
index 45190da8..b7f69f89 100644
--- a/src/catch2/benchmark/detail/catch_stats.cpp
+++ b/src/catch2/benchmark/detail/catch_stats.cpp
@@ -25,8 +25,8 @@ namespace {
using Catch::Benchmark::Detail::sample;
template <typename URng, typename Estimator>
- sample resample(URng& rng, int resamples, std::vector<double>::iterator first, std::vector<double>::iterator last, Estimator& estimator) {
- auto n = last - first;
+ sample resample(URng& rng, unsigned int resamples, std::vector<double>::iterator first, std::vector<double>::iterator last, Estimator& estimator) {
+ auto n = static_cast<size_t>(last - first);
std::uniform_int_distribution<decltype(n)> dist(0, n - 1);
sample out;
@@ -34,7 +34,7 @@ using Catch::Benchmark::Detail::sample;
std::generate_n(std::back_inserter(out), resamples, [n, first, &estimator, &dist, &rng] {
std::vector<double> resampled;
resampled.reserve(n);
- std::generate_n(std::back_inserter(resampled), n, [first, &dist, &rng] { return first[dist(rng)]; });
+ std::generate_n(std::back_inserter(resampled), n, [first, &dist, &rng] { return first[static_cast<std::ptrdiff_t>(dist(rng))]; });
return estimator(resampled.begin(), resampled.end());
});
std::sort(out.begin(), out.end());
@@ -194,7 +194,7 @@ namespace Catch {
}
- bootstrap_analysis analyse_samples(double confidence_level, int n_resamples, std::vector<double>::iterator first, std::vector<double>::iterator last) {
+ bootstrap_analysis analyse_samples(double confidence_level, unsigned int n_resamples, std::vector<double>::iterator first, std::vector<double>::iterator last) {
CATCH_INTERNAL_START_WARNINGS_SUPPRESSION
CATCH_INTERNAL_SUPPRESS_GLOBALS_WARNINGS
static std::random_device entropy;
diff --git a/src/catch2/benchmark/detail/catch_stats.hpp b/src/catch2/benchmark/detail/catch_stats.hpp
index 8985670f..dc2ad4ab 100644
--- a/src/catch2/benchmark/detail/catch_stats.hpp
+++ b/src/catch2/benchmark/detail/catch_stats.hpp
@@ -59,7 +59,7 @@ namespace Catch {
template <typename Estimator, typename Iterator>
sample jackknife(Estimator&& estimator, Iterator first, Iterator last) {
- auto n = last - first;
+ auto n = static_cast<size_t>(last - first);
auto second = first;
++second;
sample results;
@@ -115,8 +115,8 @@ namespace Catch {
double b2 = bias - z1;
double a1 = a(b1);
double a2 = a(b2);
- auto lo = (std::max)(cumn(a1), 0);
- auto hi = (std::min)(cumn(a2), n - 1);
+ auto lo = static_cast<size_t>((std::max)(cumn(a1), 0));
+ auto hi = static_cast<size_t>((std::min)(cumn(a2), n - 1));
return { point, resample[lo], resample[hi], confidence_level };
}
@@ -129,7 +129,7 @@ namespace Catch {
double outlier_variance;
};
- bootstrap_analysis analyse_samples(double confidence_level, int n_resamples, std::vector<double>::iterator first, std::vector<double>::iterator last);
+ bootstrap_analysis analyse_samples(double confidence_level, unsigned int n_resamples, std::vector<double>::iterator first, std::vector<double>::iterator last);
} // namespace Detail
} // namespace Benchmark
} // namespace Catch