ACloudViewer  3.9.4
A Modern Library for 3D Data Processing
Timer.h
Go to the documentation of this file.
1 // ----------------------------------------------------------------------------
2 // - CloudViewer: www.cloudViewer.org -
3 // ----------------------------------------------------------------------------
4 // Copyright (c) 2018-2024 www.cloudViewer.org
5 // SPDX-License-Identifier: MIT
6 // ----------------------------------------------------------------------------
7 
8 #pragma once
9 
10 // LOCAL
11 #include "CVCoreLib.h"
12 
13 // SYSTEM
14 #include <string>
15 
16 namespace cloudViewer {
17 namespace utility {
18 
20 public:
21  Timer();
22  ~Timer();
23 
24 public:
25  static double GetSystemTimeInMilliseconds();
26 
27 public:
28  void Start();
29  void Stop();
30  void Print(const std::string &timer_info) const;
31  double GetDurationInSecond() const;
32  double GetDurationInMillisecond() const;
33  std::tuple<int, int, double> GetDurationInHMS() const;
34 
35 private:
36  double start_time_in_milliseconds_;
37  double end_time_in_milliseconds_;
38 };
39 
41 public:
42  ScopeTimer(const std::string &scope_timer_info = "");
43  ~ScopeTimer();
44 
45 private:
46  std::string scope_timer_info_;
47 };
48 
49 class CV_CORE_LIB_API FPSTimer : public Timer {
50 public:
51  FPSTimer(const std::string &fps_timer_info = "",
52  int expectation = -1,
53  double time_to_print = 3000.0,
54  int events_to_print = 100);
55 
59  void Signal();
60 
61 private:
62  std::string fps_timer_info_;
63  int expectation_;
64  double time_to_print_;
65  int events_to_print_;
66  int event_fragment_count_;
67  int event_total_count_;
68 };
69 
70 } // namespace utility
71 } // namespace cloudViewer
#define CV_CORE_LIB_API
Definition: CVCoreLibWin.h:15
Generic file read and write utility for python interface.