Storm 1.14.0.1
A Modern Probabilistic Model Checker
Loading...
Searching...
No Matches
ProgressMeasurement.h
Go to the documentation of this file.
1#pragma once
2
3#include <boost/optional.hpp>
4#include <chrono>
5#include <cstdint>
6#include <ostream>
7
8namespace storm {
9namespace utility {
10
11// The default minimal delay (in seconds) between two progress messages, used when no specific delay is requested.
12constexpr uint64_t defaultProgressMeasurementDelay = 5;
13
18 public:
19 typedef decltype(std::chrono::duration_cast<std::chrono::seconds>(std::chrono::seconds::zero()).count()) SecondType;
20 typedef decltype(std::chrono::duration_cast<std::chrono::milliseconds>(std::chrono::milliseconds::zero()).count()) MilisecondType;
21 typedef decltype(std::chrono::duration_cast<std::chrono::nanoseconds>(std::chrono::nanoseconds::zero()).count()) NanosecondType;
22
29 ProgressMeasurement(std::string const& itemName, uint64_t delay = defaultProgressMeasurementDelay);
30
35 void startNewMeasurement(uint64_t startCount);
36
43 bool updateProgress(uint64_t count);
44
52 bool updateProgress(uint64_t count, std::ostream& outstream);
53
57 bool isMaxCountSet() const;
58
62 uint64_t getMaxCount() const;
63
67 void setMaxCount(uint64_t maxCount);
68
72 void unsetMaxCount();
73
77 uint64_t getShowProgressDelay() const;
78
83 void setShowProgressDelay(uint64_t delay);
84
88 std::string const& getItemName() const;
89
94 void setItemName(std::string const& name);
95
96 private:
97 // The delay (in seconds) between progress emission.
98 uint64_t delay;
99 // A name for what this is measuring (iterations, states, ...)
100 std::string itemName;
101
102 // The maximal count that can be achieved. numeric_limits<uint64_t>::max() means unspecified.
103 uint64_t maxCount;
104
105 // The last displayed count
106 uint64_t lastDisplayedCount;
107
108 std::chrono::high_resolution_clock::time_point timeOfStart;
109 std::chrono::high_resolution_clock::time_point timeOfLastMessage;
110};
111
112} // namespace utility
113} // namespace storm
decltype(std::chrono::duration_cast< std::chrono::seconds >(std::chrono::seconds::zero()).count()) SecondType
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.
decltype(std::chrono::duration_cast< std::chrono::nanoseconds >(std::chrono::nanoseconds::zero()).count()) NanosecondType
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.
ProgressMeasurement(std::string const &itemName, uint64_t delay=defaultProgressMeasurementDelay)
Initializes progress measurement.
decltype(std::chrono::duration_cast< std::chrono::milliseconds >(std::chrono::milliseconds::zero()).count()) MilisecondType
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.
constexpr uint64_t defaultProgressMeasurementDelay