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();
|
||||
}
|
||||
|
||||
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)); }
|
||||
|
||||
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.
|
||||
double ToSeconds(Duration duration);
|
||||
double ToSeconds(std::chrono::steady_clock::duration duration);
|
||||
|
||||
// Creates a time from a Universal Time Scale.
|
||||
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();
|
||||
work_queue_->push_back({now, work_item});
|
||||
kWorkQueueDelayMetric->Set(
|
||||
std::chrono::duration_cast<std::chrono::duration<double>>(
|
||||
now - work_queue_->front().time)
|
||||
.count());
|
||||
common::ToSeconds(now - work_queue_->front().time));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -149,9 +149,7 @@ void PoseGraph3D::AddWorkItem(const std::function<void()>& work_item) {
|
|||
const auto now = std::chrono::steady_clock::now();
|
||||
work_queue_->push_back({now, work_item});
|
||||
kWorkQueueDelayMetric->Set(
|
||||
std::chrono::duration_cast<std::chrono::duration<double>>(
|
||||
now - work_queue_->front().time)
|
||||
.count());
|
||||
common::ToSeconds(now - work_queue_->front().time));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue