NASA Astrobee Robot Software  0.19.1
Flight software for the Astrobee robots operating inside the International Space Station.
rate_timer.h
Go to the documentation of this file.
1 /* Copyright (c) 2017, United States Government, as represented by the
2  * Administrator of the National Aeronautics and Space Administration.
3  *
4  * All rights reserved.
5  *
6  * The Astrobee platform is licensed under the Apache License, Version 2.0
7  * (the "License"); you may not use this file except in compliance with the
8  * License. You may obtain a copy of the License at
9  *
10  * http://www.apache.org/licenses/LICENSE-2.0
11  *
12  * Unless required by applicable law or agreed to in writing, software
13  * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
14  * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
15  * License for the specific language governing permissions and limitations
16  * under the License.
17  */
18 
19 #ifndef LOCALIZATION_COMMON_RATE_TIMER_H_
20 #define LOCALIZATION_COMMON_RATE_TIMER_H_
21 
24 
25 #include <boost/optional.hpp>
26 
27 #include <chrono>
28 #include <string>
29 
30 namespace localization_common {
31 class RateTimer {
32  public:
33  explicit RateTimer(const std::string& timer_name = "");
34  boost::optional<double> LastValue();
35  void Record();
36  void Log() const;
37  void LogEveryN(const int num_events_per_log) const;
38  void VlogEveryN(const int num_events_per_log, const int level) const;
39  void RecordAndLog();
40  void RecordAndLogEveryN(const int num_events_per_log);
41  void RecordAndVlogEveryN(const int num_events_per_log, const int level);
42  void Vlog(const int level = 2) const;
43 
44  private:
45  std::chrono::time_point<std::chrono::steady_clock> start_time_;
46  Averager averager_;
47  int num_events_;
48 };
49 } // namespace localization_common
50 
51 #endif // LOCALIZATION_COMMON_RATE_TIMER_H_
localization_common
Definition: averager.h:33
localization_common::RateTimer::LastValue
boost::optional< double > LastValue()
Definition: rate_timer.cc:37
localization_common::RateTimer::RecordAndLogEveryN
void RecordAndLogEveryN(const int num_events_per_log)
Definition: rate_timer.cc:47
localization_common::RateTimer::Log
void Log() const
Definition: rate_timer.cc:57
localization_common::RateTimer::Vlog
void Vlog(const int level=2) const
Definition: rate_timer.cc:72
localization_common::Averager
Definition: averager.h:34
averager.h
localization_common::RateTimer
Definition: rate_timer.h:31
time.h
localization_common::RateTimer::VlogEveryN
void VlogEveryN(const int num_events_per_log, const int level) const
Definition: rate_timer.cc:67
localization_common::RateTimer::Record
void Record()
Definition: rate_timer.cc:23
localization_common::RateTimer::RateTimer
RateTimer(const std::string &timer_name="")
Definition: rate_timer.cc:22
localization_common::RateTimer::RecordAndLog
void RecordAndLog()
Definition: rate_timer.cc:42
localization_common::RateTimer::LogEveryN
void LogEveryN(const int num_events_per_log) const
Definition: rate_timer.cc:62
localization_common::RateTimer::RecordAndVlogEveryN
void RecordAndVlogEveryN(const int num_events_per_log, const int level)
Definition: rate_timer.cc:52