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
15 public:
16 typedef decltype(std::chrono::duration_cast<std::chrono::seconds>(std::chrono::seconds::zero()).count()) SecondType;
17 typedef decltype(std::chrono::duration_cast<std::chrono::milliseconds>(std::chrono::milliseconds::zero()).count()) MilisecondType;
18 typedef decltype(std::chrono::duration_cast<std::chrono::nanoseconds>(std::chrono::nanoseconds::zero()).count()) NanosecondType;
19
24 ProgressMeasurement(std::string const& itemName = "items");
25
30 void startNewMeasurement(uint64_t startCount);
31
38 bool updateProgress(uint64_t count);
39
47 bool updateProgress(uint64_t count, std::ostream& outstream);
48
52 bool isMaxCountSet() const;
53
57 uint64_t getMaxCount() const;
58
62 void setMaxCount(uint64_t maxCount);
63
67 void unsetMaxCount();
68
72 uint64_t getShowProgressDelay() const;
73
78 void setShowProgressDelay(uint64_t delay);
79
83 std::string const& getItemName() const;
84
89 void setItemName(std::string const& name);
90
91 private:
92 // The delay (in seconds) between progress emission.
93 uint64_t delay;
94 // A name for what this is measuring (iterations, states, ...)
95 std::string itemName;
96
97 // The maximal count that can be achieved. numeric_limits<uint64_t>::max() means unspecified.
98 uint64_t maxCount;
99
100 // The last displayed count
101 uint64_t lastDisplayedCount;
102
103 std::chrono::high_resolution_clock::time_point timeOfStart;
104 std::chrono::high_resolution_clock::time_point timeOfLastMessage;
105};
106
107} // namespace utility
108} // namespace storm
ProgressMeasurement(std::string const &itemName="items")
Initializes progress measurement.
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.
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.