- not a floating point value, which will revert to scientific notation once
it gets big.
- behave for negative spans
Signed-off-by: Sage Weil <sage@redhat.com>
}
std::ostream& operator<<(std::ostream& m, const timespan& t) {
- return m << std::chrono::duration<double>(t).count() << "s";
+ int64_t ns = t.count();
+ if (ns < 0) {
+ ns = -ns;
+ m << "-";
+ }
+ m << (ns / 1000000000ll);
+ ns %= 1000000000ll;
+ if (ns) {
+ char oldfill = m.fill();
+ m.fill('0');
+ m << '.' << std::setw(9) << ns;
+ m.fill(oldfill);
+ }
+ return m << "s";
}
template<typename Clock,