src
stopwatch.cpp
Go to the documentation of this file.
1
27
#include <
tesseract_common/stopwatch.h
>
28
29
namespace
tesseract_common
30
{
31
void
Stopwatch::start
()
32
{
33
start_time_
= Clock::now();
34
running_
=
true
;
35
}
36
37
void
Stopwatch::stop
()
38
{
39
end_time_
= Clock::now();
40
running_
=
false
;
41
}
42
43
double
Stopwatch::elapsedMilliseconds
()
const
44
{
45
if
(
running_
)
46
return
std::chrono::duration<double, std::milli>(Clock::now() -
start_time_
).count();
47
48
return
std::chrono::duration<double, std::milli>(
end_time_
-
start_time_
).count();
49
}
50
51
double
Stopwatch::elapsedSeconds
()
const
{
return
(
elapsedMilliseconds
() / 1000.0); }
52
53
}
// namespace tesseract_common
tesseract_common
Definition:
allowed_collision_matrix.h:19
tesseract_common::Stopwatch::stop
void stop()
Stop the timer.
Definition:
stopwatch.cpp:37
tesseract_common::Stopwatch::end_time_
std::chrono::time_point< Clock > end_time_
Definition:
stopwatch.h:64
tesseract_common::Stopwatch::start_time_
std::chrono::time_point< Clock > start_time_
Definition:
stopwatch.h:63
tesseract_common::Stopwatch::elapsedSeconds
double elapsedSeconds() const
Get the elapsed time in seconds.
Definition:
stopwatch.cpp:51
tesseract_common::Stopwatch::elapsedMilliseconds
double elapsedMilliseconds() const
Get the elapsed time in milliseconds.
Definition:
stopwatch.cpp:43
tesseract_common::Stopwatch::start
void start()
Start the timer.
Definition:
stopwatch.cpp:31
tesseract_common::Stopwatch::running_
bool running_
Definition:
stopwatch.h:65
stopwatch.h
Simple stopwatch class using chrono.
tesseract_common
Author(s): Levi Armstrong
autogenerated on Sun May 18 2025 03:01:40