15 delay = generalSettings.getShowProgressDelay();
19 lastDisplayedCount = startCount;
20 timeOfStart = std::chrono::high_resolution_clock::now();
21 timeOfLastMessage = timeOfStart;
25 bool progressPrinted =
false;
28 return progressPrinted;
30 return progressPrinted;
34 auto now = std::chrono::high_resolution_clock::now();
36 auto durationSinceLastMessage =
static_cast<uint64_t
>(std::chrono::duration_cast<std::chrono::milliseconds>(now - this->timeOfLastMessage).count());
37 if (durationSinceLastMessage >= this->delay * 1000) {
38 double itemsPerSecond = (
static_cast<double>(count - this->lastDisplayedCount) * 1000.0 /
static_cast<double>(durationSinceLastMessage));
39 outstream <<
"Completed " << count <<
" " << itemName <<
" " << (this->
isMaxCountSet() ?
"(out of " + std::to_string(this->
getMaxCount()) +
") " :
"")
40 <<
"in " << std::chrono::duration_cast<std::chrono::seconds>(now - timeOfStart).count() <<
"s (currently " << itemsPerSecond <<
" "
41 << itemName <<
" per second).\n";
42 timeOfLastMessage = std::chrono::high_resolution_clock::now();
43 lastDisplayedCount = count;
50 return this->maxCount < std::numeric_limits<uint64_t>::max();
55 return this->maxCount;
59 this->maxCount = maxCount;
63 this->maxCount = std::numeric_limits<uint64_t>::max();
75 return this->itemName;
79 this->itemName = name;
ProgressMeasurement(std::string const &itemName="items")
Initializes progress measurement.
bool isMaxCountSet() const
Returns whether a maximal count (which is required to achieve 100% progress) has been specified.
std::string const & getItemName() const
Returns the current name of what we are counting (e.g.
bool updateProgress(uint64_t count)
Updates the progress to the current count and logs it (on the progress log channel) if the delay pass...
uint64_t getShowProgressDelay() const
Returns the currently specified minimal delay (in seconds) between two progress messages.
void setMaxCount(uint64_t maxCount)
Sets the maximal possible count.
void startNewMeasurement(uint64_t startCount)
Starts a new measurement, dropping all progress information collected so far.
void setItemName(std::string const &name)
Customizes the name of what we are counting (e.g.
uint64_t getMaxCount() const
Returns the maximal possible count (if specified).
void unsetMaxCount()
Erases a previously specified maximal count.
void setShowProgressDelay(uint64_t delay)
Customizes the minimal delay between two progress messages.
#define STORM_LOG_PROGRESS_LAZY(...)
#define STORM_LOG_ASSERT(cond, message)
SettingsType const & getModule()
Get module.
ValueType max(ValueType const &first, ValueType const &second)