18#include <sys/resource.h>
59 if (s.empty())
return;
61 std::regex re(
"^([0-9]*\\.?[0-9]+)|((([0-9]+)(h|min|s|ms|us|ns))+)$", std::regex::extended);
62 std::regex nre(
"([0-9]+)(h|min|s|ms|us|ns)", std::regex::extended);
67 if (!std::regex_match(s, match, re))
goto error;
70 submatch = match[1].str();
71 if (match[1].matched) {
73 auto value = std::stod(submatch);
74 if (errno)
goto error;
76 std::chrono::duration<double> d(value);
77 duration = std::chrono::duration_cast<std::chrono::microseconds>(d);
81 submatch = match[2].str();
82 for (std::smatch m; std::regex_search(submatch, m, nre); submatch = m.suffix()) {
84 const auto value = std::stoull(m[1]);
85 if (errno)
goto error;
102 klee_error(
"Illegal number format: %s", s.c_str());
146time::Span::operator time::Duration()
const {
return duration; }
148time::Span::operator bool()
const {
return duration.count() != 0; }
150time::Span::operator timeval()
const {
152 const auto secs = std::chrono::duration_cast<std::chrono::seconds>(duration);
153 const auto usecs = std::chrono::duration_cast<std::chrono::microseconds>(duration - secs);
154 tv.tv_sec = secs.count();
155 tv.tv_usec = usecs.count();
160 return (std::uint64_t)std::chrono::duration_cast<std::chrono::microseconds>(duration).count();
164 return std::chrono::duration_cast<std::chrono::nanoseconds>(duration).count() / (double)1000000000;
169 const auto h = std::chrono::duration_cast<std::chrono::hours>(d);
170 const auto m = std::chrono::duration_cast<std::chrono::minutes>(d -= h);
171 const auto s = std::chrono::duration_cast<std::chrono::seconds>(d -= m);
173 return std::make_tuple((std::uint32_t) h.count(), (std::uint8_t) m.count(), (std::uint8_t) s.count());
180 std::stringstream buffer;
181 buffer <<
"Using monotonic steady clock with "
182 << std::chrono::steady_clock::period::num
184 << std::chrono::steady_clock::period::den
193 auto ret = ::getrusage(RUSAGE_SELF, &
usage);
196 klee_warning(
"getrusage returned with error, return (0,0)");
207 return time::Point(std::chrono::steady_clock::now());
bool operator>(const Point &, const Point &)
Span microseconds(std::uint64_t)
Point operator+(const Point &, const Span &)
Span getUserTime()
Returns time spent by this process in user mode.
Span nanoseconds(std::uint64_t)
Span minutes(std::uint16_t)
Span operator/(const Span &, unsigned)
Span hours(std::uint16_t)
time spans
Point getWallTime()
Returns point in time using a monotonic steady clock.
bool operator>=(const Point &, const Point &)
Span operator*(const Span &, double)
std::string getClockInfo()
Returns information about clock.
bool operator<=(const Point &, const Point &)
bool operator==(const Point &, const Point &)
Span seconds(std::uint64_t)
Span milliseconds(std::uint64_t)
bool operator!=(const Point &, const Point &)
bool operator<(const Point &, const Point &)
std::ostream & operator<<(std::ostream &, Span)
Span -> "X.Ys".
Point operator-(const Point &, const Span &)
void klee_error(const char *msg,...) __attribute__((format(printf
void void void klee_warning(const char *msg,...) __attribute__((format(printf
Point & operator-=(const Span &)
std::tuple< std::uint32_t, std::uint8_t, std::uint8_t > toHMS() const
std::uint64_t toMicroseconds() const
Span & operator*=(unsigned)
Span & operator-=(const Span &)
Span & operator=(const Duration &)
Span & operator+=(const Span &)