Browse Source

Update progress measurments only if --progress flag is set

tempestpy_adaptions
Matthias Volk 4 years ago
parent
commit
6dcbf75fe3
No known key found for this signature in database GPG Key ID: 83A57678F739FCD3
  1. 4
      src/storm/settings/modules/GeneralSettings.cpp
  2. 7
      src/storm/settings/modules/GeneralSettings.h
  3. 11
      src/storm/utility/ProgressMeasurement.cpp
  4. 15
      src/storm/utility/ProgressMeasurement.h

4
src/storm/settings/modules/GeneralSettings.cpp

@ -66,6 +66,10 @@ namespace storm {
return this->getOption(verboseOptionName).getHasOptionBeenSet(); return this->getOption(verboseOptionName).getHasOptionBeenSet();
} }
bool GeneralSettings::isShowProgressSet() const {
return this->getOption(showProgressOptionName).getHasOptionBeenSet();
}
uint64_t GeneralSettings::getShowProgressDelay() const { uint64_t GeneralSettings::getShowProgressDelay() const {
return this->getOption(showProgressOptionName).getArgumentByName("delay").getValueAsUnsignedInteger(); return this->getOption(showProgressOptionName).getArgumentByName("delay").getValueAsUnsignedInteger();
} }

7
src/storm/settings/modules/GeneralSettings.h

@ -50,6 +50,13 @@ namespace storm {
*/ */
bool isVerboseSet() const; bool isVerboseSet() const;
/*!
* Retrieves whether the progress option was set.
*
* @return True if the progress option was set.
*/
bool isShowProgressSet() const;
/*! /*!
* Retrieves the delay for printing information about the exploration progress. * Retrieves the delay for printing information about the exploration progress.
* *

11
src/storm/utility/ProgressMeasurement.cpp

@ -11,7 +11,9 @@ namespace storm {
namespace utility { namespace utility {
ProgressMeasurement::ProgressMeasurement(std::string const& itemName) : itemName(itemName), maxCount(std::numeric_limits<uint64_t>::max()) { ProgressMeasurement::ProgressMeasurement(std::string const& itemName) : itemName(itemName), maxCount(std::numeric_limits<uint64_t>::max()) {
delay = storm::settings::getModule<storm::settings::modules::GeneralSettings>().getShowProgressDelay();
auto generalSettings = storm::settings::getModule<storm::settings::modules::GeneralSettings>();
showProgress = generalSettings.isShowProgressSet();
delay = generalSettings.getShowProgressDelay();
} }
void ProgressMeasurement::startNewMeasurement(uint64_t startCount) { void ProgressMeasurement::startNewMeasurement(uint64_t startCount) {
@ -21,14 +23,15 @@ namespace storm {
} }
bool ProgressMeasurement::updateProgress(uint64_t count) { bool ProgressMeasurement::updateProgress(uint64_t count) {
if (showProgress) {
std::stringstream stream; std::stringstream stream;
if (updateProgress(count, stream)) { if (updateProgress(count, stream)) {
std::string message = stream.str(); std::string message = stream.str();
// Remove the line break at the end of the message.
message.pop_back();
STORM_LOG_INFO(message);
// Message already contains line break at the end.
STORM_PRINT_AND_LOG(message);
return true; return true;
} }
}
return false; return false;
} }

15
src/storm/utility/ProgressMeasurement.h

@ -29,19 +29,23 @@ namespace storm {
void startNewMeasurement(uint64_t startCount); void startNewMeasurement(uint64_t startCount);
/*! /*!
* Updates the progress to the current count.
* Updates the progress to the current count and prints it if the delay passed.
* The progress is only updated and printed if the ShowProgress setting is enabled.
*
* @param count The currently achieved count. * @param count The currently achieved count.
* @return true iff the progress was printed (i.e., the delay passed).
* @return True iff the progress was printed (i.e., the delay passed and showProgress setting enabled).
*/ */
bool updateProgress(uint64_t count); bool updateProgress(uint64_t count);
/*! /*!
* Updates the progress to the current count. * Updates the progress to the current count.
* The update and printing is done independently of the showProgress setting.
*
* @param count The currently achieved count. * @param count The currently achieved count.
* @param outstream The stream to which the progress is printed (if the delay passed) * @param outstream The stream to which the progress is printed (if the delay passed)
* @return true iff the progress was printed (i.e., the delay passed)
* @return True iff the progress was printed (i.e., the delay passed)
*/ */
bool updateProgress(uint64_t value, std::ostream& outstream);
bool updateProgress(uint64_t count, std::ostream& outstream);
/*! /*!
* Returns whether a maximal count (which is required to achieve 100% progress) has been specified * Returns whether a maximal count (which is required to achieve 100% progress) has been specified
@ -87,6 +91,9 @@ namespace storm {
private: private:
// Whether progress should be printed to standard output.
bool showProgress;
// The delay (in seconds) between progress emission. // The delay (in seconds) between progress emission.
uint64_t delay; uint64_t delay;
// A name for what this is measuring (iterations, states, ...) // A name for what this is measuring (iterations, states, ...)

Loading…
Cancel
Save