mirror of
https://github.com/ceph/ceph
synced 2025-02-23 11:07:35 +00:00
common/ceph_time: make operator<< for timespan less useless
- 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>
This commit is contained in:
parent
ad03fb5b80
commit
353a0e5fac
@ -100,7 +100,20 @@ namespace ceph {
|
||||
}
|
||||
|
||||
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,
|
||||
|
Loading…
Reference in New Issue
Block a user