Open3D (C++ API)  0.18.0+252c867
Timer.h
Go to the documentation of this file.
1 // ----------------------------------------------------------------------------
2 // - Open3D: www.open3d.org -
3 // ----------------------------------------------------------------------------
4 // Copyright (c) 2018-2023 www.open3d.org
5 // SPDX-License-Identifier: MIT
6 // ----------------------------------------------------------------------------
7 
8 #pragma once
9 
10 #include <string>
11 
12 namespace open3d {
13 namespace utility {
14 
15 class Timer {
16 public:
17  Timer();
18  ~Timer();
19 
20 public:
21  static double GetSystemTimeInMilliseconds();
22 
23 public:
24  void Start();
25  void Stop();
26  void Print(const std::string &timer_info) const;
27  double GetDurationInSecond() const;
28  double GetDurationInMillisecond() const;
29  std::tuple<int, int, double> GetDurationInHMS() const;
30 
31 private:
32  double start_time_in_milliseconds_;
33  double end_time_in_milliseconds_;
34 };
35 
36 class ScopeTimer : public Timer {
37 public:
38  ScopeTimer(const std::string &scope_timer_info = "");
39  ~ScopeTimer();
40 
41 private:
42  std::string scope_timer_info_;
43 };
44 
45 class FPSTimer : public Timer {
46 public:
47  FPSTimer(const std::string &fps_timer_info = "",
48  int expectation = -1,
49  double time_to_print = 3000.0,
50  int events_to_print = 100);
51 
55  void Signal();
56 
57 private:
58  std::string fps_timer_info_;
59  int expectation_;
60  double time_to_print_;
61  int events_to_print_;
62  int event_fragment_count_;
63  int event_total_count_;
64 };
65 
66 } // namespace utility
67 } // namespace open3d
Definition: Timer.h:45
void Signal()
Definition: Timer.cpp:80
FPSTimer(const std::string &fps_timer_info="", int expectation=-1, double time_to_print=3000.0, int events_to_print=100)
Definition: Timer.cpp:67
Definition: Timer.h:36
ScopeTimer(const std::string &scope_timer_info="")
Definition: Timer.cpp:57
~ScopeTimer()
Definition: Timer.cpp:62
Definition: Timer.h:15
double GetDurationInSecond() const
Definition: Timer.cpp:40
std::tuple< int, int, double > GetDurationInHMS() const
Definition: Timer.cpp:44
~Timer()
Definition: Timer.cpp:20
void Print(const std::string &timer_info) const
Definition: Timer.cpp:52
double GetDurationInMillisecond() const
Definition: Timer.cpp:36
void Start()
Definition: Timer.cpp:28
static double GetSystemTimeInMilliseconds()
Definition: Timer.cpp:22
void Stop()
Definition: Timer.cpp:32
Timer()
Definition: Timer.cpp:17
Definition: PinholeCameraIntrinsic.cpp:16