51Clock::Clock(TTime iStartTime):
52 frequency_(impl::ClockImpl::frequency())
54 resolution_ = num::NumTraits<TTime>::one /
static_cast<TTime
>(frequency_);
60void Clock::reset(TTime iStartTime)
62 startTick_ = impl::ClockImpl::tick();
63 startTime_ = iStartTime;
68const std::string Clock::humanize(
const TTime& time)
70 std::ostringstream buffer;
71 buffer.copyfmt(std::cout);
75 buffer.setf(std::ios_base::showpoint);
76 buffer.setf(
static_cast<std::ios_base::fmtflags
>(0), std::ios_base::floatfield);
80 buffer << (1e12 * time) <<
"ps";
84 buffer << (1e9 * time) <<
"ns";
88 buffer << (1e6 * time) <<
"us";
92 buffer << (1e3 * time) <<
"ms";
96 buffer << time <<
"s";
103 static void write(std::ostringstream& stream, TTime time,
const std::string& bigUnit, TTime SmallInBig,
const std::string& smallUnit)
105 const TTime
sign = num::sign(time);
106 const TTime absTime = num::abs(time);
107 const TTime bigHand = num::floor(absTime);
108 const TTime smallHand = num::floor(SmallInBig * (absTime - bigHand));
109 stream << static_cast<int>(
sign * bigHand) << bigUnit << std::setw(2) << std::setfill('0') << static_cast<int>(smallHand) << smallUnit;
115 Helper::write(buffer, time / 60,
"m", 60,
"s");
117 else if (time < 86400)
119 Helper::write(buffer, time / 3600,
"h", 60,
"m");
123 Helper::write(buffer, time / 86400,
"d", 24,
"h");
T sign(const T &x)
if x < 0 return -1, else if x > 0 return 1, else return 0.
general utility, debug facilities, ...
Library for Assembled Shared Sources.