9 #ifndef LLVM_SUPPORT_CHRONO_H 10 #define LLVM_SUPPORT_CHRONO_H 32 template <
typename D = std::chrono::nanoseconds>
33 using TimePoint = std::chrono::time_point<std::chrono::system_clock, D>;
38 return system_clock::to_time_t(
39 time_point_cast<system_clock::time_point::duration>(TP));
46 return time_point_cast<seconds>(system_clock::from_time_t(T));
53 return time_point_cast<nanoseconds>(system_clock::from_time_t(T))
59 raw_ostream &operator<<(raw_ostream &OS, sys::TimePoint<> TP);
100 template <
typename Period>
struct unit {
static const char value[]; };
103 template <>
struct unit<
std::ratio<3600>> {
static const char value[]; };
104 template <>
struct unit<
std::ratio<60>> {
static const char value[]; };
105 template <>
struct unit<
std::ratio<1>> {
static const char value[]; };
106 template <>
struct unit<
std::milli> {
static const char value[]; };
107 template <>
struct unit<
std::micro> {
static const char value[]; };
108 template <>
struct unit<
std::nano> {
static const char value[]; };
111 template <
typename Rep,
typename Period>
114 typedef std::chrono::duration<Rep, Period> Dur;
115 typedef typename std::conditional<
116 std::chrono::treat_as_floating_point<Rep>::value, double, intmax_t>
::type 119 template <
typename AsPeriod>
static InternalRep getAs(
const Dur &
D) {
121 return duration_cast<duration<InternalRep, AsPeriod>>(
D).
count();
124 static std::pair<InternalRep, StringRef> consumeUnit(
StringRef &
Style,
128 return {getAs<std::nano>(
D),
"ns"};
130 return {getAs<std::micro>(
D),
"us"};
132 return {getAs<std::milli>(
D),
"ms"};
134 return {getAs<std::ratio<1>>(
D),
"s"};
136 return {getAs<std::ratio<60>>(
D),
"m"};
138 return {getAs<std::ratio<3600>>(
D),
"h"};
142 static bool consumeShowUnit(
StringRef &Style) {
149 assert(0 &&
"Unrecognised duration format");
157 std::tie(count, unit) = consumeUnit(Style, D);
158 bool show_unit = consumeShowUnit(Style);
164 Stream <<
" " << unit;
171 #endif // LLVM_SUPPORT_CHRONO_H
This class represents lattice values for constants.
bool consume_front(StringRef Prefix)
Returns true if this StringRef has the given prefix and removes that prefix.
format_object< Ts... > format(const char *Fmt, const Ts &... Vals)
These are helper functions used to produce formatted output.
LLVM_NODISCARD bool empty() const
empty - Check if the string is empty.
auto count(R &&Range, const E &Element) -> typename std::iterator_traits< decltype(adl_begin(Range))>::difference_type
Wrapper function around std::count to count the number of times an element Element occurs in the give...
std::time_t toTimeT(TimePoint<> TP)
Convert a TimePoint to std::time_t.
static GCRegistry::Add< StatepointGC > D("statepoint-example", "an example strategy for statepoint")
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
This class implements an extremely fast bulk output stream that can only output to a stream...
StringRef - Represent a constant reference to a string, i.e.
TimePoint< std::chrono::seconds > toTimePoint(std::time_t T)
Convert a std::time_t to a TimePoint.
std::chrono::time_point< std::chrono::system_clock, D > TimePoint
A time point on the system clock.