mirror of
https://github.com/catchorg/Catch2.git
synced 2025-08-03 13:55:39 +02:00
Added --skip-benchmarks command-line option. (#2408)
Closes #2392 Co-authored-by: Martin Hořeňovský <martin.horenovsky@gmail.com>
This commit is contained in:
@@ -95,8 +95,11 @@ namespace Catch {
|
||||
// sets lambda to be used in fun *and* executes benchmark!
|
||||
template <typename Fun, std::enable_if_t<!Detail::is_related<Fun, Benchmark>::value, int> = 0>
|
||||
Benchmark & operator=(Fun func) {
|
||||
fun = Detail::BenchmarkFunction(func);
|
||||
run();
|
||||
auto const* cfg = getCurrentContext().getConfig();
|
||||
if (!cfg->skipBenchmarks()) {
|
||||
fun = Detail::BenchmarkFunction(func);
|
||||
run();
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
@@ -152,6 +152,7 @@ namespace Catch {
|
||||
bool Config::showInvisibles() const { return m_data.showInvisibles; }
|
||||
Verbosity Config::verbosity() const { return m_data.verbosity; }
|
||||
|
||||
bool Config::skipBenchmarks() const { return m_data.skipBenchmarks; }
|
||||
bool Config::benchmarkNoAnalysis() const { return m_data.benchmarkNoAnalysis; }
|
||||
unsigned int Config::benchmarkSamples() const { return m_data.benchmarkSamples; }
|
||||
double Config::benchmarkConfidenceInterval() const { return m_data.benchmarkConfidenceInterval; }
|
||||
|
@@ -64,6 +64,7 @@ namespace Catch {
|
||||
unsigned int shardCount = 1;
|
||||
unsigned int shardIndex = 0;
|
||||
|
||||
bool skipBenchmarks = false;
|
||||
bool benchmarkNoAnalysis = false;
|
||||
unsigned int benchmarkSamples = 100;
|
||||
double benchmarkConfidenceInterval = 0.95;
|
||||
@@ -129,6 +130,7 @@ namespace Catch {
|
||||
int abortAfter() const override;
|
||||
bool showInvisibles() const override;
|
||||
Verbosity verbosity() const override;
|
||||
bool skipBenchmarks() const override;
|
||||
bool benchmarkNoAnalysis() const override;
|
||||
unsigned int benchmarkSamples() const override;
|
||||
double benchmarkConfidenceInterval() const override;
|
||||
|
@@ -88,6 +88,7 @@ namespace Catch {
|
||||
virtual std::vector<std::string> const& getSectionsToRun() const = 0;
|
||||
virtual Verbosity verbosity() const = 0;
|
||||
|
||||
virtual bool skipBenchmarks() const = 0;
|
||||
virtual bool benchmarkNoAnalysis() const = 0;
|
||||
virtual unsigned int benchmarkSamples() const = 0;
|
||||
virtual double benchmarkConfidenceInterval() const = 0;
|
||||
|
@@ -296,6 +296,9 @@ namespace Catch {
|
||||
| Opt( setWaitForKeypress, "never|start|exit|both" )
|
||||
["--wait-for-keypress"]
|
||||
( "waits for a keypress before exiting" )
|
||||
| Opt( config.skipBenchmarks)
|
||||
["--skip-benchmarks"]
|
||||
( "disable running benchmarks")
|
||||
| Opt( config.benchmarkSamples, "samples" )
|
||||
["--benchmark-samples"]
|
||||
( "number of samples to collect (default: 100)" )
|
||||
|
Reference in New Issue
Block a user