Purpose
Aims of the project
PhoenixClock is a C++ library designed to provide precise and flexible time management utilities for scientific and technical applications. It offers tools for high-resolution timing, synchronization, and time conversion, making it easier to handle time-related operations across different platforms and environments. The library focuses on reliability, accuracy, and ease of use, supporting modern C++ standards and best practices. By abstracting complex time handling logic, PhoenixClock enables developers to concentrate on their core application features.
Key objectives
- Deliver efficient and reusable utilities for time measurement, synchronization, and conversion in C++.
- Ensure modularity and straightforward integration into other projects.
- Support modern C++ standards and compilers.
- Provide a robust build system using CMake.
- Facilitate cross-platform development with consistent and reliable time management
Quick start
This project aims to ease the use of clock in complex environments, especially distributed environments where latencies measurement has to be precise and reproductible when running unit tests. PhoenixClock provide PGenericClock, a template classe which takes two arguments :
- The main clock backend (could be clock, PClockNs for nanoseconds, etc)
- A mock of a clock, PClockMock, which can play, register and replay a sequence of clock calls
These clocks are activated with a mode PClockMode::PClockMode which can be :
PClockMode::NO_MOCK: for a normal usagePClockMode::MOCK: when the mock the desired clock is playedPClockMode::MOCK_RECORD: when the real clock backend is used but the clock mock is recording (could be usefull for debugging or to desing new unit tests quickly)
#include "phoenix_clock.h"
...
///Example of PGenericClock usage
void callingClock(){
PGenericClock<PClockBackend, PClockMock> myClock;
//Let's use the normal mode
myClock.setMode(PClockMode::NO_MOCK);
//We can get the current time with
clock.now(); //Returns a time_t such as clock()
//Once we have a mock file 'clock.clockmock',
//we can replay it with the same API
myClock.setMode(PClockMode::MOCK);
clock.now(); //Returns a time_t such as clock(),
//but this time, it is from the recorded times in the mock
//Let's have an example of the recording
myClock.setMode(PClockMode::MOCK_RECORD);
clock.now(); //Returns a time_t such as clock(),
//but this time, it is from the real clock backend but is
//recorded at the same time in the mock
}