Stopwatch.h
Go to the documentation of this file.
1
#ifndef STOPWATCH_H
2
#define STOPWATCH_H
3
4
#include <chrono>
5
#include <map>
6
#include <ostream>
7
8
namespace
stopwatch
9
{
10
using
Clock
= std::chrono::system_clock;
11
using
Duration
= std::chrono::duration<float>;
// seconds
12
using
TimePoint
= std::chrono::time_point<Clock>;
13
14
class
Stats
15
{
16
public
:
17
Stats
() :
numExecutions
(0) { }
18
19
std::size_t
numExecutions
;
20
Duration
totalExecutionTime
;
21
22
Duration
averageExecutionTime
;
23
Duration
latestExecutionTime
;
24
25
friend
std::ostream&
operator<<
(std::ostream& os,
const
Stats
& stats);
26
27
};
28
29
30
class
Stopwatch
31
{
32
33
public
:
34
Stopwatch
();
35
36
void
reset
();
37
void
start
(
const
std::string& tag);
38
void
stop
(
const
std::string& tag);
39
40
const
Stats
&
getStats
(
const
std::string& tag);
41
42
friend
std::ostream&
operator<<
(std::ostream& os,
const
Stopwatch
& stats);
43
44
private
:
45
46
std::map<std::string, Stats> statsMap;
47
std::map<std::string, TimePoint> currentStarts;
48
49
};
50
51
}
52
53
#endif // STOPWATCH_H
stopwatch::TimePoint
std::chrono::time_point< Clock > TimePoint
Definition:
Stopwatch.h:12
stopwatch::Stats::Stats
Stats()
Definition:
Stopwatch.h:17
stopwatch::Stats::latestExecutionTime
Duration latestExecutionTime
Definition:
Stopwatch.h:23
stopwatch::Stats::numExecutions
std::size_t numExecutions
Definition:
Stopwatch.h:19
stopwatch::Stats::totalExecutionTime
Duration totalExecutionTime
Definition:
Stopwatch.h:20
stopwatch::Stats::operator<<
friend std::ostream & operator<<(std::ostream &os, const Stats &stats)
Definition:
Stopwatch.cpp:50
stopwatch::Stopwatch::Stopwatch
Stopwatch()
Definition:
Stopwatch.cpp:6
stopwatch::Stopwatch::reset
void reset()
Definition:
Stopwatch.cpp:11
stopwatch::Stats
Definition:
Stopwatch.h:14
stopwatch
Definition:
Stopwatch.cpp:4
stopwatch::Stopwatch::getStats
const Stats & getStats(const std::string &tag)
Definition:
Stopwatch.cpp:45
stopwatch::Stopwatch::stop
void stop(const std::string &tag)
Definition:
Stopwatch.cpp:23
stopwatch::Stopwatch
Definition:
Stopwatch.h:30
stopwatch::Duration
std::chrono::duration< float > Duration
Definition:
Stopwatch.h:11
stopwatch::Stats::averageExecutionTime
Duration averageExecutionTime
Definition:
Stopwatch.h:22
stopwatch::Stopwatch::start
void start(const std::string &tag)
Definition:
Stopwatch.cpp:17
stopwatch::Stopwatch::operator<<
friend std::ostream & operator<<(std::ostream &os, const Stopwatch &stats)
Definition:
Stopwatch.cpp:58
stopwatch::Clock
std::chrono::system_clock Clock
Definition:
Stopwatch.h:10
VisionX
components
pointcloud_provider
CoFusionProcessor
Stopwatch.h
Generated on Sat Oct 12 2024 09:14:17 for armarx_documentation by
1.8.17