Instrument Neutral Distributed Interface INDI  1.9.5
fpsmeter.h
Go to the documentation of this file.
1 /*
2  Copyright (C) 2020 by Pawel Soja <kernel32.pl@gmail.com>
3  FPS Meter
4 
5  This library is free software; you can redistribute it and/or
6  modify it under the terms of the GNU Lesser General Public
7  License as published by the Free Software Foundation; either
8  version 2.1 of the License, or (at your option) any later version.
9 
10  This library is distributed in the hope that it will be useful,
11  but WITHOUT ANY WARRANTY; without even the implied warranty of
12  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13  Lesser General Public License for more details.
14 
15  You should have received a copy of the GNU Lesser General Public
16  License along with this library; if not, write to the Free Software
17  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
18 
19 */
20 #pragma once
21 
22 #include <chrono>
23 #include <cstdint>
24 
25 namespace INDI
26 {
27 class FPSMeter
28 {
29 public:
30  FPSMeter(double timeWindow = 1000);
31 
32 public:
36  void reset();
37 
42  bool newFrame();
43 
48  void setTimeWindow(double timeWindow);
49 
50 public:
54  double framesPerSecond() const;
58  double deltaTime() const;
59 
64  uint64_t totalFrames() const;
65 
70  double totalTime() const;
71 
72 private:
73  uint64_t mFramesPerElapsedTime = 0;
74  double mElapsedTime = 0;
75  double mTimeWindow = 1000;
76 
77  std::chrono::steady_clock::time_point mFrameTime1;
78  std::chrono::steady_clock::time_point mFrameTime2;
79 
80  double mFramesPerSecond = 0;
81 
82  double mTotalTime = 0;
83  uint64_t mTotalFrames = 0;
84 
85 };
86 }
INDI::FPSMeter::framesPerSecond
double framesPerSecond() const
Number of frames per second counted in the time window.
Definition: fpsmeter.cpp:60
INDI::FPSMeter::setTimeWindow
void setTimeWindow(double timeWindow)
Time window setup.
Definition: fpsmeter.cpp:55
INDI::FPSMeter::totalFrames
uint64_t totalFrames() const
Total frames.
Definition: fpsmeter.cpp:70
INDI::FPSMeter::reset
void reset()
Reset all frame information.
Definition: fpsmeter.cpp:80
INDI::FPSMeter::FPSMeter
FPSMeter(double timeWindow=1000)
Definition: fpsmeter.cpp:25
INDI::FPSMeter::deltaTime
double deltaTime() const
Time in milliseconds between last frames.
Definition: fpsmeter.cpp:65
INDI
Namespace to encapsulate INDI client, drivers, and mediator classes.
Definition: AlignmentSubsystemForClients.cpp:11
INDI::FPSMeter::newFrame
bool newFrame()
When you get a frame, call the function to count.
Definition: fpsmeter.cpp:31
INDI::FPSMeter
Definition: fpsmeter.h:27
INDI::FPSMeter::totalTime
double totalTime() const
Total time.
Definition: fpsmeter.cpp:75