micro-test-plus 6.0.0
µTest++ Testing Framework
Loading...
Searching...
No Matches
stopwatch.h File Reference

C++ header file with declarations for the µTest++ stopwatch. More...

#include <chrono>
#include <cstdint>
#include <ctime>
#include "inlines/stopwatch-inlines.h"

Go to the source code of this file.

Classes

class  micro_os_plus::micro_test_plus::detail::stopwatch
 Measures the elapsed time of an operation. More...

Namespaces

namespace  micro_os_plus
 The primary namespace for the µOS++ framework.
namespace  micro_os_plus::micro_test_plus
 Primary namespace for the µTest++ testing framework.
namespace  micro_os_plus::micro_test_plus::detail
 Internal implementation details for the µTest++ framework.

Functions

void micro_os_plus::micro_test_plus::detail::read_clock (timespec &ts) noexcept
 Reads the system clock.

Detailed Description

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.

Definition in file stopwatch.h.