mirror of
https://github.com/catchorg/Catch2.git
synced 2025-08-01 21:05:39 +02:00
Various improvements to the benchmarking support
* Units from <ratio> are no longer redeclared in our own namespace * The default clock is `steady_clock`, not `high_resolution_clock`, because, as HH says "high_resolution_clock is useless. If you want measure the passing of time, use steady_clock. If you want user friendly time, use system_clock". * Benchmarking support is opt-in, not opt-out, to avoid the large (~10%) compile time penalty. * Benchmarking-related options in CLI are always present, to decrease the amount of code that is only compiled conditionally and making the whole shebang more maintainble.
This commit is contained in:
@@ -463,7 +463,6 @@ TEST_CASE( "Process can be configured on command line", "[config][command-line]"
|
||||
}
|
||||
}
|
||||
|
||||
#ifndef CATCH_CONFIG_DISABLE_BENCHMARKING
|
||||
SECTION("Benchmark options") {
|
||||
SECTION("samples") {
|
||||
CHECK(cli.parse({ "test", "--benchmark-samples=200" }));
|
||||
@@ -489,5 +488,4 @@ TEST_CASE( "Process can be configured on command line", "[config][command-line]"
|
||||
REQUIRE(config.benchmarkNoAnalysis);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
@@ -7,7 +7,7 @@
|
||||
*/
|
||||
|
||||
#include "catch.hpp"
|
||||
#ifndef CATCH_CONFIG_DISABLE_BENCHMARKING
|
||||
#if defined(CATCH_CONFIG_ENABLE_BENCHMARKING)
|
||||
namespace {
|
||||
struct manual_clock {
|
||||
public:
|
||||
@@ -402,4 +402,4 @@ TEST_CASE("run benchmark", "[benchmark]") {
|
||||
|
||||
CHECK((end - start).count() == 2867251000);
|
||||
}
|
||||
#endif // CATCH_CONFIG_DISABLE_BENCHMARKING
|
||||
#endif // CATCH_CONFIG_ENABLE_BENCHMARKING
|
||||
|
@@ -2,7 +2,7 @@
|
||||
|
||||
#include <map>
|
||||
|
||||
#ifndef CATCH_CONFIG_DISABLE_BENCHMARKING
|
||||
#if defined(CATCH_CONFIG_ENABLE_BENCHMARKING)
|
||||
std::uint64_t Fibonacci(std::uint64_t number);
|
||||
|
||||
std::uint64_t Fibonacci(std::uint64_t number) {
|
||||
@@ -127,4 +127,4 @@ TEST_CASE("Benchmark containers", "[!benchmark]") {
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif // CATCH_CONFIG_DISABLE_BENCHMARKING
|
||||
#endif // CATCH_CONFIG_ENABLE_BENCHMARKING
|
||||
|
Reference in New Issue
Block a user