17 #ifndef CARTOGRAPHER_COMMON_RATE_TIMER_H_ 18 #define CARTOGRAPHER_COMMON_RATE_TIMER_H_ 36 template <
typename ClockType = std::chrono::steady_clock>
53 return static_cast<double>(
events_.size() - 1) /
65 std::chrono::duration_cast<std::chrono::duration<double>>(
85 std::ostringstream out;
86 out << std::fixed << std::setprecision(2) <<
ComputeRate() <<
" Hz " 102 std::vector<double> result;
103 result.reserve(count);
104 for (
size_t i = 0; i !=
count; ++i) {
114 const double sum = std::accumulate(deltas.begin(), deltas.end(), 0.);
115 const double mean = sum / deltas.size();
117 double squared_sum = 0.;
118 for (
const double x : deltas) {
121 const double sigma = std::sqrt(squared_sum / (deltas.size() - 1));
123 std::ostringstream out;
124 out << std::scientific << std::setprecision(2) << mean <<
" s +/- " << sigma
136 #endif // CARTOGRAPHER_COMMON_RATE_TIMER_H_ double ComputeWallTimeRateRatio() const
const common::Duration window_duration_
std::deque< Event > events_
UniversalTimeScaleClock::time_point Time
RateTimer & operator=(const RateTimer &)=delete
std::vector< double > ComputeDeltasInSeconds() const
UniversalTimeScaleClock::duration Duration
RateTimer(const common::Duration window_duration)
double ComputeRate() const
std::string DebugString() const
double ToSeconds(const Duration duration)
std::string DeltasDebugString() const
ClockType::time_point wall_time
void Pulse(common::Time time)