Introduce common::ToSeconds for std::chrono::steady_clock::duration. (#1244)
Introduce a new overload of ToSeconds for std::chrono::steady_clock and use it for the work queue delay metric.master
parent
eff103f663
commit
9e54a981c6
|
@ -31,6 +31,11 @@ double ToSeconds(const Duration duration) {
|
||||||
.count();
|
.count();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
double ToSeconds(const std::chrono::steady_clock::duration duration) {
|
||||||
|
return std::chrono::duration_cast<std::chrono::duration<double>>(duration)
|
||||||
|
.count();
|
||||||
|
}
|
||||||
|
|
||||||
Time FromUniversal(const int64 ticks) { return Time(Duration(ticks)); }
|
Time FromUniversal(const int64 ticks) { return Time(Duration(ticks)); }
|
||||||
|
|
||||||
int64 ToUniversal(const Time time) { return time.time_since_epoch().count(); }
|
int64 ToUniversal(const Time time) { return time.time_since_epoch().count(); }
|
||||||
|
|
|
@ -49,6 +49,7 @@ Duration FromMilliseconds(int64 milliseconds);
|
||||||
|
|
||||||
// Returns the given duration in seconds.
|
// Returns the given duration in seconds.
|
||||||
double ToSeconds(Duration duration);
|
double ToSeconds(Duration duration);
|
||||||
|
double ToSeconds(std::chrono::steady_clock::duration duration);
|
||||||
|
|
||||||
// Creates a time from a Universal Time Scale.
|
// Creates a time from a Universal Time Scale.
|
||||||
Time FromUniversal(int64 ticks);
|
Time FromUniversal(int64 ticks);
|
||||||
|
|
|
@ -151,9 +151,7 @@ void PoseGraph2D::AddWorkItem(const std::function<void()>& work_item) {
|
||||||
const auto now = std::chrono::steady_clock::now();
|
const auto now = std::chrono::steady_clock::now();
|
||||||
work_queue_->push_back({now, work_item});
|
work_queue_->push_back({now, work_item});
|
||||||
kWorkQueueDelayMetric->Set(
|
kWorkQueueDelayMetric->Set(
|
||||||
std::chrono::duration_cast<std::chrono::duration<double>>(
|
common::ToSeconds(now - work_queue_->front().time));
|
||||||
now - work_queue_->front().time)
|
|
||||||
.count());
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -149,9 +149,7 @@ void PoseGraph3D::AddWorkItem(const std::function<void()>& work_item) {
|
||||||
const auto now = std::chrono::steady_clock::now();
|
const auto now = std::chrono::steady_clock::now();
|
||||||
work_queue_->push_back({now, work_item});
|
work_queue_->push_back({now, work_item});
|
||||||
kWorkQueueDelayMetric->Set(
|
kWorkQueueDelayMetric->Set(
|
||||||
std::chrono::duration_cast<std::chrono::duration<double>>(
|
common::ToSeconds(now - work_queue_->front().time));
|
||||||
now - work_queue_->front().time)
|
|
||||||
.count());
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue