YARP
Yet Another Robot Platform
 
Loading...
Searching...
No Matches
FpsStats.h
Go to the documentation of this file.
1/*
2 * SPDX-FileCopyrightText: 2006-2021 Istituto Italiano di Tecnologia (IIT)
3 * SPDX-FileCopyrightText: 2006-2010 RobotCub Consortium
4 * SPDX-License-Identifier: LGPL-2.1-or-later
5 */
6
7#ifndef FPSSTATS
8#define FPSSTATS
9
10#include <yarp/os/Time.h>
11
16{
17public:
18 double average;
19 double max;
20 double min;
21 unsigned int iterations;
22 double t0;
23 double prev;
24
26 reset();
27 }
28
33 void reset(){
34 average=0;
35 max=0;
36 min=1e20;
37 iterations=0;
39 }
40
45 void update(){
46 double now=yarp::os::Time::now();
47
48 if (iterations>0){
49 double dt=now-prev;
50
51 if (dt > max) {
52 max = dt;
53 }
54 if (dt < min) {
55 min = dt;
56 }
57 }
58
59 prev=now;
60 iterations++;
61 }
67 void getStats(double &av, double &m, double &M)
68 {
69 if (iterations>0){
71 m=min;
72 M=max;
73 }
74 else{
75 av=0;
76 m=0;
77 M=0;
78 }
79 }
80
84 void getStats(double &av){
85 if (iterations > 0) {
87 } else {
88 av = 0;
89 }
90 }
91};
92
93#endif
Class used for calculate the fps.
Definition FpsStats.h:16
void getStats(double &av)
This function returns the Average value.
Definition FpsStats.h:84
unsigned int iterations
Definition FpsStats.h:21
FpsStats()
Definition FpsStats.h:25
void update()
This function must be called each time you want to track a frame.
Definition FpsStats.h:45
double max
Definition FpsStats.h:19
double average
Definition FpsStats.h:18
double prev
Definition FpsStats.h:23
void getStats(double &av, double &m, double &M)
This function returns the Minimum, Maximum and Average values.
Definition FpsStats.h:67
double t0
Definition FpsStats.h:22
void reset()
This function must be called each time you want to reset the acquiring data period Typically if you w...
Definition FpsStats.h:33
double min
Definition FpsStats.h:20
double now()
Return the current time in seconds, relative to an arbitrary starting point.
Definition Time.cpp:121