Remove CATCH_CONFIG_ENABLE_BENCHMARKING compilation toggle

Now that Catch2 is a proper library, we can always build the full
library (comparatively minor slowdown) and the user can avoid
including benchmarking headers to avoid the compilation slowdown.
This commit is contained in:
Martin Hořeňovský committed 2020-02-06 11:36:46 +01:00
1 parent 86e19b952d
commit cd7d7a1c67
38 files changed
+2377 -88

No files matched your search

@@ -0,0 +1,14 @@
/*
* Distributed under the Boost Software License, Version 1.0. (See accompanying
* file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
*/
#include <catch2/benchmark/catch_chronometer.hpp>
namespace Catch {
namespace Benchmark {
namespace Detail {
ChronometerConcept::~ChronometerConcept() = default;
} // namespace Detail
} // namespace Benchmark
} // namespace Catch
+1 -1
View File
@@ -22,7 +22,7 @@ namespace Catch {
struct ChronometerConcept {
virtual void start() = 0;
virtual void finish() = 0;
virtual ~ChronometerConcept() = default;
virtual ~ChronometerConcept(); // = default;
};
template <typename Clock>
struct ChronometerModel final : public ChronometerConcept {
+3
View File
@@ -15,6 +15,9 @@
# include <atomic> // atomic_thread_fence
#endif
#include <type_traits>
#include <utility>
namespace Catch {
namespace Benchmark {
#if defined(__GNUC__) || defined(__clang__)
@@ -0,0 +1,14 @@
/*
* Distributed under the Boost Software License, Version 1.0. (See accompanying
* file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
*/
#include <catch2/benchmark/detail/catch_benchmark_function.hpp>
namespace Catch {
namespace Benchmark {
namespace Detail {
BenchmarkFunction::callable::~callable() = default;
} // namespace Detail
} // namespace Benchmark
} // namespace Catch
@@ -1,4 +1,4 @@
/*
/*
* Created by Joachim on 16/04/2019.
* Adapted from donated nonius code.
*
@@ -41,7 +41,7 @@ namespace Catch {
struct callable {
virtual void call(Chronometer meter) const = 0;
virtual callable* clone() const = 0;
virtual ~callable() = default;
virtual ~callable(); // = default;
};
template <typename Fun>
struct model : public callable {
@@ -0,0 +1,14 @@
/*
* Distributed under the Boost Software License, Version 1.0. (See accompanying
* file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
*/
#include <catch2/benchmark/detail/catch_complete_invoke.hpp>
namespace Catch {
namespace Benchmark {
namespace Detail {
const std::string benchmarkErrorMsg = "a benchmark failed to run successfully";
} // namespace Detail
} // namespace Benchmark
} // namespace Catch
@@ -12,6 +12,8 @@
#define TWOBLUECUBES_CATCH_DETAIL_COMPLETE_INVOKE_HPP_INCLUDED
#include <catch2/catch_enforce.h>
#include <catch2/catch_interfaces_capture.h>
#include <catch2/catch_interfaces_registry_hub.h>
#include <type_traits>
#include <utility>
@@ -51,7 +53,7 @@ namespace Catch {
return CompleteInvoker<ResultOf_t<Fun(Args...)>>::invoke(std::forward<Fun>(fun), std::forward<Args>(args)...);
}
const std::string benchmarkErrorMsg = "a benchmark failed to run successfully";
extern const std::string benchmarkErrorMsg;
} // namespace Detail
template <typename Fun>
@@ -0,0 +1,29 @@
/*
* Distributed under the Boost Software License, Version 1.0. (See accompanying
* file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
*/
// Run a function for a minimum amount of time
#include <catch2/benchmark/detail/catch_run_for_at_least.hpp>
#include <exception>
#include <catch2/catch_enforce.h>
namespace Catch {
namespace Benchmark {
namespace Detail {
struct optimized_away_error : std::exception {
const char* what() const noexcept override;
};
const char* optimized_away_error::what() const noexcept {
return "could not measure benchmark, maybe it was optimized away";
}
void throw_optimized_away_error() {
Catch::throw_exception(optimized_away_error{});
}
} // namespace Detail
} // namespace Benchmark
} // namespace Catch
@@ -39,11 +39,9 @@ namespace Catch {
template <typename Clock, typename Fun>
using run_for_at_least_argument_t = typename std::conditional<is_callable<Fun(Chronometer)>::value, Chronometer, int>::type;
struct optimized_away_error : std::exception {
const char* what() const noexcept override {
return "could not measure benchmark, maybe it was optimized away";
}
};
[[noreturn]]
void throw_optimized_away_error();
template <typename Clock, typename Fun>
TimingOf<Clock, Fun(run_for_at_least_argument_t<Clock, Fun>)> run_for_at_least(ClockDuration<Clock> how_long, int seed, Fun&& fun) {
@@ -56,7 +54,7 @@ namespace Catch {
}
iters *= 2;
}
throw optimized_away_error{};
throw_optimized_away_error();
}
} // namespace Detail
} // namespace Benchmark
@@ -8,8 +8,6 @@
// Statistical analysis tools
#if defined(CATCH_CONFIG_ENABLE_BENCHMARKING)
#include <catch2/benchmark/detail/catch_stats.hpp>
#include <catch2/catch_compiler_capabilities.h>
@@ -220,5 +218,3 @@ namespace Catch {
} // namespace Detail
} // namespace Benchmark
} // namespace Catch
#endif // CATCH_CONFIG_ENABLE_BENCHMARKING
@@ -23,6 +23,7 @@
#include <cmath>
#include <utility>
#include <cstddef>
#include <random>
namespace Catch {
namespace Benchmark {