mirror of
				https://github.com/catchorg/Catch2.git
				synced 2025-10-31 20:27:11 +01:00 
			
		
		
		
	Added config to control multiple of clock resolution to run benchmark iterations for
This commit is contained in:
		| @@ -12,7 +12,11 @@ | ||||
|  | ||||
| namespace Catch { | ||||
|  | ||||
|     void BenchmarkLooper::reportStart() const { | ||||
|     auto BenchmarkLooper::getResolution() -> uint64_t { | ||||
|         return getEstimatedClockResolution() * getCurrentContext().getConfig()->benchmarkResolutionMultiple(); | ||||
|     } | ||||
|  | ||||
|     void BenchmarkLooper::reportStart() { | ||||
|         getResultCapture().benchmarkStarting( { m_name } ); | ||||
|     } | ||||
|     auto BenchmarkLooper::needsMoreIterations() -> bool { | ||||
|   | ||||
| @@ -23,11 +23,13 @@ namespace Catch { | ||||
|         size_t m_iterationsToRun = 1; | ||||
|         uint64_t m_resolution; | ||||
|         Timer m_timer; | ||||
|  | ||||
|         static auto getResolution() -> uint64_t; | ||||
|     public: | ||||
|         // Keep most of this inline as it's on the code path that is being timed | ||||
|         BenchmarkLooper( StringRef name ) | ||||
|         :   m_name( name.c_str() ), | ||||
|             m_resolution( getEstimatedClockResolution()*10 ) | ||||
|             m_resolution( getResolution() ) | ||||
|         { | ||||
|             reportStart(); | ||||
|             m_timer.start(); | ||||
| @@ -43,7 +45,7 @@ namespace Catch { | ||||
|             ++m_count; | ||||
|         } | ||||
|  | ||||
|         void reportStart() const; | ||||
|         void reportStart(); | ||||
|         auto needsMoreIterations() -> bool; | ||||
|     }; | ||||
|  | ||||
|   | ||||
| @@ -153,6 +153,9 @@ namespace Catch { | ||||
|             + Opt( setColourUsage, "yes|no" ) | ||||
|                 ["--use-colour"] | ||||
|                 ( "should output be colourised" ) | ||||
|             + Opt( config.benchmarkResolutionMultiple, "multiplier" ) | ||||
|                 ["--benchmark-resolution-multiple"] | ||||
|                 ( "multiple of clock resolution to run benchmarks" ) | ||||
|  | ||||
|             + Arg( config.testsOrTags, "test name|pattern|tags" ) | ||||
|                 ( "which test or tests to use" ); | ||||
|   | ||||
| @@ -49,6 +49,7 @@ namespace Catch { | ||||
|     ShowDurations::OrNot Config::showDurations() const { return m_data.showDurations; } | ||||
|     RunTests::InWhatOrder Config::runOrder() const     { return m_data.runOrder; } | ||||
|     unsigned int Config::rngSeed() const               { return m_data.rngSeed; } | ||||
|     int Config::benchmarkResolutionMultiple() const    { return m_data.benchmarkResolutionMultiple; } | ||||
|     UseColour::YesOrNo Config::useColour() const       { return m_data.useColour; } | ||||
|     bool Config::shouldDebugBreak() const              { return m_data.shouldDebugBreak; } | ||||
|     int Config::abortAfter() const                     { return m_data.abortAfter; } | ||||
|   | ||||
| @@ -38,6 +38,7 @@ namespace Catch { | ||||
|  | ||||
|         int abortAfter = -1; | ||||
|         unsigned int rngSeed = 0; | ||||
|         int benchmarkResolutionMultiple = 10; | ||||
|  | ||||
|         Verbosity verbosity = Verbosity::Normal; | ||||
|         WarnAbout::What warnings = WarnAbout::Nothing; | ||||
| @@ -88,6 +89,7 @@ namespace Catch { | ||||
|         ShowDurations::OrNot showDurations() const override; | ||||
|         RunTests::InWhatOrder runOrder() const override; | ||||
|         unsigned int rngSeed() const override; | ||||
|         int benchmarkResolutionMultiple() const override; | ||||
|         UseColour::YesOrNo useColour() const override; | ||||
|         bool shouldDebugBreak() const override; | ||||
|         int abortAfter() const override; | ||||
|   | ||||
| @@ -62,6 +62,7 @@ namespace Catch { | ||||
|         virtual TestSpec const& testSpec() const = 0; | ||||
|         virtual RunTests::InWhatOrder runOrder() const = 0; | ||||
|         virtual unsigned int rngSeed() const = 0; | ||||
|         virtual int benchmarkResolutionMultiple() const = 0; | ||||
|         virtual UseColour::YesOrNo useColour() const = 0; | ||||
|         virtual std::vector<std::string> const& getSectionsToRun() const = 0; | ||||
|         virtual Verbosity verbosity() const = 0; | ||||
|   | ||||
		Reference in New Issue
	
	Block a user
	 Phil Nash
					Phil Nash