mirror of
https://github.com/catchorg/Catch2.git
synced 2025-08-01 21:05:39 +02:00
Replace vector iterator args in benchmarks with ptr args
This commit is contained in:
@@ -156,8 +156,12 @@ TEST_CASE("uniform samples", "[benchmark]") {
|
||||
std::vector<double> samples(100);
|
||||
std::fill(samples.begin(), samples.end(), 23);
|
||||
|
||||
using it = std::vector<double>::iterator;
|
||||
auto e = Catch::Benchmark::Detail::bootstrap(0.95, samples.begin(), samples.end(), samples, [](it a, it b) {
|
||||
auto e = Catch::Benchmark::Detail::bootstrap(
|
||||
0.95,
|
||||
samples.data(),
|
||||
samples.data() + samples.size(),
|
||||
samples,
|
||||
[]( double const* a, double const* b ) {
|
||||
auto sum = std::accumulate(a, b, 0.);
|
||||
return sum / (b - a);
|
||||
});
|
||||
@@ -198,7 +202,7 @@ TEST_CASE("normal_quantile", "[benchmark]") {
|
||||
TEST_CASE("mean", "[benchmark]") {
|
||||
std::vector<double> x{ 10., 20., 14., 16., 30., 24. };
|
||||
|
||||
auto m = Catch::Benchmark::Detail::mean(x.begin(), x.end());
|
||||
auto m = Catch::Benchmark::Detail::mean(x.data(), x.data() + x.size());
|
||||
|
||||
REQUIRE(m == 19.);
|
||||
}
|
||||
@@ -206,9 +210,9 @@ TEST_CASE("mean", "[benchmark]") {
|
||||
TEST_CASE("weighted_average_quantile", "[benchmark]") {
|
||||
std::vector<double> x{ 10., 20., 14., 16., 30., 24. };
|
||||
|
||||
auto q1 = Catch::Benchmark::Detail::weighted_average_quantile(1, 4, x.begin(), x.end());
|
||||
auto med = Catch::Benchmark::Detail::weighted_average_quantile(1, 2, x.begin(), x.end());
|
||||
auto q3 = Catch::Benchmark::Detail::weighted_average_quantile(3, 4, x.begin(), x.end());
|
||||
auto q1 = Catch::Benchmark::Detail::weighted_average_quantile(1, 4, x.data(), x.data() + x.size());
|
||||
auto med = Catch::Benchmark::Detail::weighted_average_quantile(1, 2, x.data(), x.data() + x.size());
|
||||
auto q3 = Catch::Benchmark::Detail::weighted_average_quantile(3, 4, x.data(), x.data() + x.size());
|
||||
|
||||
REQUIRE(q1 == 14.5);
|
||||
REQUIRE(med == 18.);
|
||||
@@ -227,7 +231,8 @@ TEST_CASE("classify_outliers", "[benchmark]") {
|
||||
SECTION("none") {
|
||||
std::vector<double> x{ 10., 20., 14., 16., 30., 24. };
|
||||
|
||||
auto o = Catch::Benchmark::Detail::classify_outliers(x.begin(), x.end());
|
||||
auto o = Catch::Benchmark::Detail::classify_outliers(
|
||||
x.data(), x.data() + x.size() );
|
||||
|
||||
REQUIRE(o.samples_seen == static_cast<int>(x.size()));
|
||||
require_outliers(o, 0, 0, 0, 0);
|
||||
@@ -235,7 +240,8 @@ TEST_CASE("classify_outliers", "[benchmark]") {
|
||||
SECTION("low severe") {
|
||||
std::vector<double> x{ -12., 20., 14., 16., 30., 24. };
|
||||
|
||||
auto o = Catch::Benchmark::Detail::classify_outliers(x.begin(), x.end());
|
||||
auto o = Catch::Benchmark::Detail::classify_outliers(
|
||||
x.data(), x.data() + x.size() );
|
||||
|
||||
REQUIRE(o.samples_seen == static_cast<int>(x.size()));
|
||||
require_outliers(o, 1, 0, 0, 0);
|
||||
@@ -243,7 +249,8 @@ TEST_CASE("classify_outliers", "[benchmark]") {
|
||||
SECTION("low mild") {
|
||||
std::vector<double> x{ 1., 20., 14., 16., 30., 24. };
|
||||
|
||||
auto o = Catch::Benchmark::Detail::classify_outliers(x.begin(), x.end());
|
||||
auto o = Catch::Benchmark::Detail::classify_outliers(
|
||||
x.data(), x.data() + x.size() );
|
||||
|
||||
REQUIRE(o.samples_seen == static_cast<int>(x.size()));
|
||||
require_outliers(o, 0, 1, 0, 0);
|
||||
@@ -251,7 +258,8 @@ TEST_CASE("classify_outliers", "[benchmark]") {
|
||||
SECTION("high mild") {
|
||||
std::vector<double> x{ 10., 20., 14., 16., 36., 24. };
|
||||
|
||||
auto o = Catch::Benchmark::Detail::classify_outliers(x.begin(), x.end());
|
||||
auto o = Catch::Benchmark::Detail::classify_outliers(
|
||||
x.data(), x.data() + x.size() );
|
||||
|
||||
REQUIRE(o.samples_seen == static_cast<int>(x.size()));
|
||||
require_outliers(o, 0, 0, 1, 0);
|
||||
@@ -259,7 +267,8 @@ TEST_CASE("classify_outliers", "[benchmark]") {
|
||||
SECTION("high severe") {
|
||||
std::vector<double> x{ 10., 20., 14., 16., 49., 24. };
|
||||
|
||||
auto o = Catch::Benchmark::Detail::classify_outliers(x.begin(), x.end());
|
||||
auto o = Catch::Benchmark::Detail::classify_outliers(
|
||||
x.data(), x.data() + x.size() );
|
||||
|
||||
REQUIRE(o.samples_seen == static_cast<int>(x.size()));
|
||||
require_outliers(o, 0, 0, 0, 1);
|
||||
@@ -267,7 +276,8 @@ TEST_CASE("classify_outliers", "[benchmark]") {
|
||||
SECTION("mixed") {
|
||||
std::vector<double> x{ -20., 20., 14., 16., 39., 24. };
|
||||
|
||||
auto o = Catch::Benchmark::Detail::classify_outliers(x.begin(), x.end());
|
||||
auto o = Catch::Benchmark::Detail::classify_outliers(
|
||||
x.data(), x.data() + x.size() );
|
||||
|
||||
REQUIRE(o.samples_seen == static_cast<int>(x.size()));
|
||||
require_outliers(o, 1, 0, 1, 0);
|
||||
|
Reference in New Issue
Block a user