Skip to content

Commit

Permalink
WIP: Detemplatize analyse
Browse files Browse the repository at this point in the history
  • Loading branch information
horenmar committed Sep 1, 2023
1 parent d2b35ee commit 1710b81
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 5 deletions.
2 changes: 1 addition & 1 deletion src/catch2/benchmark/catch_benchmark.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ namespace Catch {
return plan.template run<Clock>(*cfg, env);
});

auto analysis = Detail::analyse(*cfg, samples.begin(), samples.end());
auto analysis = Detail::analyse(*cfg, samples.data(), samples.data() + samples.size());
BenchmarkStats<> stats{ CATCH_MOVE(info), CATCH_MOVE(analysis.samples), analysis.mean, analysis.standard_deviation, analysis.outliers, analysis.outlier_variance };
getResultCapture().benchmarkEnded(stats);
} CATCH_CATCH_ANON (TestFailureException const&) {
Expand Down
3 changes: 1 addition & 2 deletions src/catch2/benchmark/detail/catch_analyse.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,7 @@
namespace Catch {
namespace Benchmark {
namespace Detail {
template <typename Iterator>
SampleAnalysis analyse(const IConfig &cfg, Iterator first, Iterator last) {
inline SampleAnalysis analyse(const IConfig &cfg, FDuration* first, FDuration* last) {
if (!cfg.benchmarkNoAnalysis()) {
std::vector<double> samples;
samples.reserve(static_cast<size_t>(last - first));
Expand Down
4 changes: 2 additions & 2 deletions tests/SelfTest/IntrospectiveTests/InternalBenchmark.tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -298,7 +298,7 @@ TEST_CASE("analyse", "[approvals][benchmark]") {
samples[i] = FDuration(23 + (i % 3 - 1));
}

auto analysis = Catch::Benchmark::Detail::analyse(config, samples.begin(), samples.end());
auto analysis = Catch::Benchmark::Detail::analyse(config, samples.data(), samples.data() + samples.size());
CHECK( analysis.mean.point.count() == 23 );
CHECK( analysis.mean.lower_bound.count() < 23 );
CHECK(analysis.mean.lower_bound.count() > 22);
Expand Down Expand Up @@ -337,7 +337,7 @@ TEST_CASE("analyse no analysis", "[benchmark]") {
samples[i] = FDuration(23 + (i % 3 - 1));
}

auto analysis = Catch::Benchmark::Detail::analyse(config, samples.begin(), samples.end());
auto analysis = Catch::Benchmark::Detail::analyse(config, samples.data(), samples.data() + samples.size());
CHECK(analysis.mean.point.count() == 23);
CHECK(analysis.mean.lower_bound.count() == 23);
CHECK(analysis.mean.upper_bound.count() == 23);
Expand Down

0 comments on commit 1710b81

Please sign in to comment.