stopwatch.h File
C++ header file with declarations for the µTest++ stopwatch. More...
Included Headers
Namespaces Index
| namespace | micro_os_plus |
|
The primary namespace for the µOS++ framework. More... | |
| namespace | micro_test_plus |
|
Primary namespace for the µTest++ testing framework. More... | |
| namespace | detail |
|
Internal implementation details for the µTest++ framework. More... | |
Classes Index
| class | stopwatch |
|
Measures the elapsed time of an operation. More... | |
Functions Index
| void | read_clock (timespec &ts) noexcept |
|
Reads the system clock. More... | |
Description
C++ header file with declarations for the µTest++ stopwatch.
This header provides the stopwatch class, used to measure the elapsed time of the test suites and of the test session within the µTest++ framework. The stopwatch is started before the measured operation, stopped after it, and then reports the elapsed time as a std::chrono::microseconds duration.
Timing support relies on clock_gettime(CLOCK_MONOTONIC, ...) on POSIX platforms and on timespec_get(..., TIME_UTC) on Windows. If no clock is available (e.g. on bare-metal targets without an RTC), the readings remain zero, has_elapsed() returns false, and no timing information is reported.
All definitions reside within the micro_os_plus::micro_test_plus::detail namespace.
This file is included by micro-os-plus/micro-test-plus.h, which is the header that the applications include.
Functions
read_clock()
| noexcept |
Reads the system clock.
Isolates the platform-specific access to the system clock, used by stopwatch and by the deprecated timestamp class. The clock is monotonic on POSIX; without a clock, ts is left unchanged, so the callers clear it first when a zero value must mean that the clock was not read.
- Parameters
-
[out] ts The timespec where the reading is stored.
- Returns
Nothing.
On Windows, the current time is captured via timespec_get() with TIME_UTC. On POSIX platforms with CLOCK_MONOTONIC defined, clock_gettime(CLOCK_MONOTONIC) is used to obtain a monotonic reading. On platforms where neither macro is defined, ts is left unchanged.
Definition at line 66 of file stopwatch.cpp.
Reference micro_os_plus::micro_test_plus::detail::read_clock.
Referenced by micro_os_plus::micro_test_plus::detail::timestamp::timestamp, micro_os_plus::micro_test_plus::detail::read_clock, micro_os_plus::micro_test_plus::detail::stopwatch::start, micro_os_plus::micro_test_plus::detail::stopwatch::stop, micro_os_plus::micro_test_plus::detail::stopwatch::timestamp_begin and micro_os_plus::micro_test_plus::detail::stopwatch::timestamp_end.
File Listing
The file content with the documentation metadata removed is:
Generated via doxygen2docusaurus 2.2.8 by Doxygen 1.18.0.