NASA Astrobee Robot Software  0.19.1
Flight software for the Astrobee robots operating inside the International Space Station.
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_TIMER_H_
20 #define LOCALIZATION_COMMON_TIMER_H_
21 
24 
25 #include <chrono>
26 #include <fstream>
27 #include <string>
28 
29 namespace localization_common {
30 class Timer {
31  public:
32  explicit Timer(const std::string& timer_name = "");
33  void Start();
34  void Stop();
35  void Log() const;
36  void LogToFile(std::ofstream& ofstream) const;
37  void LogToCsv(std::ofstream& ofstream) const;
38  void LogEveryN(const int num_events_per_log) const;
39  void VlogEveryN(const int num_events_per_log, const int level) const;
40  void StopAndLog();
41  void StopAndLogEveryN(const int num_events_per_log);
42  void StopAndVlogEveryN(const int num_events_per_log, const int level);
43  void Vlog(const int level = 2) const;
44  double last_value() const;
45 
46  private:
47  std::chrono::time_point<std::chrono::steady_clock> start_time_;
48  Averager averager_;
49 };
50 } // namespace localization_common
51 
52 #endif // LOCALIZATION_COMMON_TIMER_H_
localization_common
Definition: averager.h:33
localization_common::Timer::LogToCsv
void LogToCsv(std::ofstream &ofstream) const
Definition: timer.cc:34
localization_common::Timer::VlogEveryN
void VlogEveryN(const int num_events_per_log, const int level) const
Definition: timer.cc:38
localization_common::Timer
Definition: timer.h:30
localization_common::Timer::Start
void Start()
Definition: timer.cc:23
localization_common::Timer::last_value
double last_value() const
Definition: timer.cc:59
localization_common::Timer::Log
void Log() const
Definition: timer.cc:30
localization_common::Averager
Definition: averager.h:34
localization_common::Timer::Vlog
void Vlog(const int level=2) const
Definition: timer.cc:57
localization_common::Timer::StopAndLog
void StopAndLog()
Definition: timer.cc:42
localization_common::Timer::LogToFile
void LogToFile(std::ofstream &ofstream) const
Definition: timer.cc:32
averager.h
time.h
localization_common::Timer::Stop
void Stop()
Definition: timer.cc:24
localization_common::Timer::StopAndLogEveryN
void StopAndLogEveryN(const int num_events_per_log)
Definition: timer.cc:47
localization_common::Timer::LogEveryN
void LogEveryN(const int num_events_per_log) const
Definition: timer.cc:36
localization_common::Timer::Timer
Timer(const std::string &timer_name="")
Definition: timer.cc:22
localization_common::Timer::StopAndVlogEveryN
void StopAndVlogEveryN(const int num_events_per_log, const int level)
Definition: timer.cc:52